Long answer - The HTML::Template module allows for nesting of <tmpl_loop></tmpl_loop> loop structures within the template file which in turn allows you to "dynamically" resize your output table accordingly. For example, consider the template file below ...
<table> <tmpl_loop name="row"> <tr> <tmpl_loop name="cell"> <td align="left"><tmpl_var name="cell"></td> </tmpl_loop> </tr> </tmpl_loop> </table>
... And the following now tested and working Perl code (updated 2002/03/04) ...
my $sth = $dbh->prepare(qq/ SELECT * FROM table /); $sth->execute; my @row; while (my $row = $sth->fetchrow_arrayref) { my @cell; foreach my $cell ( @{$row} ) { push @cell, { 'cell' => $cell }; } push @row, { 'cell' => \@cell}; } $html->param( 'row' => \@row ); $sth->finish;
In this example, an array-of-array-of-hashes has been built representing the nested loops within the HTML template file - When writing code which builds these data structures, I find it exceptionally useful to call upon Data::Dumper to visualise the data structure during development.
perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'
In reply to Re: Fetchall_Answer Returns
by rob_au
in thread Fetchall_Answer Returns
by growlf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |