in reply to printing out a table X wide and X down without html::template
Well, the following generates valid HTML (but not XHTML).
use constant MAX_COLS => 4; use constant MAX_ROWS => 5; my $col = 0; my $row = 0; print("<table>"); foreach my $image (@images) { print("<tr>") if !$col; print("<td>"); print(...); if (++$col == MAX_COLS) { $col = 0; if (++$row == MAX_ROWS) { last; } } } print("</table>");
Update: Bug fix. The conditions for printing <tr> and <td> were incorrect.
|
|---|