BTW, here's a little shortcut, using CGI.pm. Instead of this:
print "<table>\n"; foreach my $row (@$db_results) { print "\t<tr>\n"; foreach my $col (@$row) { print "\t\t<td>$col</td>\n"; } print "\t</tr>\n"; } print "</table>\n";
Try this:
# note that passing an array reference to Tr() creates a set of <TR> b +locks, one per element of the referenced array print table( Tr( [ map { td( $_ ) } @$db_results ] ) );
Or, if you don't like the entire table stretched out into one long line of HTML, this:
# need '*table' and '*Tr' in order to use start_table() and start_Tr() use CGI qw( :standard *table *Tr ); # ... # note the map() calls each represent a nested for() loop # and further that passing an array reference to td() creates a set of + <TD> blocks, one per element of the referenced array print join( "\n", start_table, start_Tr, (map { map { td($_) } @$_ } @$db_results), end_Tr, end_table ), "\n";
Sorry ... couldn't help "improving" on your code :)
dmm
You can give a man a fish and feed him for a day ... Or, you can teach him to fish and feed him for a lifetime
In reply to Re: (dmm): What is a multidimensional array and how do I use one
by dmmiller2k
in thread What is a multidimensional array and how do I use one
by Hopeless
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |