CGI table tidy layout possible?

J

Justin C

Can CGI print tidy html? The below code seems correct as per CGI
documentation but the output is a mess. If there's anything not
displayed right and I have to rummage through the HTML to figure out
what it is, it's not very easy because of the awfully formatted HTML.

Here's my code, my live data is sixty lines so you can imagine how that
HTML looks.

#!/usr/bin/perl
use warnings;
use strict;
use CGI qw/:standard *table/;

my $names;

while (<DATA>) {
chomp;
my ($name, $code) = split /\|/;
$names->{$name} = $code;
}

print header, start_html(), start_table(),
map {
Tr([
td([$_, $names->{$_}])
])
} sort keys %$names;
print end_table();

__DATA__
Paul McCartney|2342
John Lennon|2134
George Harrison|4432
Ringo Starr|9876


Justin.
 
J

Justin C

Can CGI print tidy html?

Very sorry to have wasted peoples' time. I've found the solution, I
wasn't searching on the correct words. Quoting CGI.pm:

"To get pretty-printed output, please use CGI::pretty..."

Justin.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top