CGI table tidy layout possible?


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.

use warnings;
use strict;
use CGI qw/:standard *table/;

my $names;

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

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

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




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

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


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