CGI table tidy layout possible?

Discussion in 'Perl Misc' started by Justin C, Dec 9, 2011.

  1. Justin C

    Justin C Guest

    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.

    --
    Justin C, by the sea.
    Justin C, Dec 9, 2011
    #1
    1. Advertising

  2. Justin C

    Justin C Guest

    On 2011-12-09, Justin C <> wrote:
    > 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.

    --
    Justin C, by the sea.
    Justin C, Dec 9, 2011
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric
    Replies:
    4
    Views:
    699
    clintonG
    Dec 24, 2004
  2. Guybrush Threepwood

    Table-based layout to CSS layout

    Guybrush Threepwood, Jun 6, 2006, in forum: HTML
    Replies:
    20
    Views:
    985
  3. Replies:
    1
    Views:
    564
    John Timney \(MVP\)
    Jun 19, 2006
  4. Habib

    Css-Layout vs Table-Layout

    Habib, Jun 19, 2006, in forum: HTML
    Replies:
    15
    Views:
    986
    Wÿrm
    Jun 20, 2006
  5. sso
    Replies:
    6
    Views:
    577
    Roedy Green
    Apr 30, 2009
Loading...

Share This Page