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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.