sravs448 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/local/bin/perl -w use strict; use CGI; my %host=( 'camel', 'flea', 'frog', 'green'); cgiout(); sub cgiout { my $q= new CGI; my $tablecontent=[$q->th(['key', 'value'])]; for (sort keys %host) { push @$tablecontent, $q->td([ $_, $host{$_} ]) ; } print $q->table( { border => 1, -width => '100%'}, $q->Tr( $tablecontent), ); }
The output I got
<table width="100%" border="1"><tr><th>key</th> <th>value</th></tr> <t +r><td>camel</td> <td>flea</td></tr> <tr><td>frog</td> <td>green</td>< +/tr></table>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Constructing HTML tables with CGI.pm
by choroba (Cardinal) on Sep 19, 2014 at 14:03 UTC | |
by sravs448 (Acolyte) on Sep 19, 2014 at 14:19 UTC | |
by choroba (Cardinal) on Sep 19, 2014 at 14:41 UTC | |
by Anonymous Monk on Sep 20, 2014 at 05:12 UTC | |
|
Re: Constructing HTML tables with CGI.pm
by NetWallah (Canon) on Sep 19, 2014 at 18:20 UTC |