a simple example, using two counters. One to keep track of the image array index, and one to keep track of the number of colums:
#!/usr/bin/perl use warnings; use strict; my @images; for (1 .. 20) { push @images, "image$_.gif";} my $x_wide = 6; # user supplied value my $output = "<table>\n"; my $i = 0; while ($i < scalar @images) { $output .= "<tr>\n"; for (my $j=0; $j<$x_wide; $j++) { if ($images[$i]) { $output .= "\t<td><img src='$images[$i]' ....></td>\n"; $i++; } } $output .= "</tr>\n"; } $output .= "</table>"; print $output;
produces a simple:
<table> <tr> <td><img src='image1.gif' ....></td> <td><img src='image2.gif' ....></td> <td><img src='image3.gif' ....></td> <td><img src='image4.gif' ....></td> <td><img src='image5.gif' ....></td> <td><img src='image6.gif' ....></td> </tr> <tr> <td><img src='image7.gif' ....></td> <td><img src='image8.gif' ....></td> <td><img src='image9.gif' ....></td> <td><img src='image10.gif' ....></td> <td><img src='image11.gif' ....></td> <td><img src='image12.gif' ....></td> </tr> <tr> <td><img src='image13.gif' ....></td> <td><img src='image14.gif' ....></td> <td><img src='image15.gif' ....></td> <td><img src='image16.gif' ....></td> <td><img src='image17.gif' ....></td> <td><img src='image18.gif' ....></td> </tr> <tr> <td><img src='image19.gif' ....></td> <td><img src='image20.gif' ....></td> </tr> </table>

In reply to Re: printing out a table X wide and X down without html::template by chakram88
in thread printing out a table X wide and X down without html::template by Anonymous Monk

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.