I just began using HTML::Template and am trying to create an HTML table. In all the examples I've read so far (POD, online), the tables are very basic -- one set of data per row and column, vis:

+--------+--------+
| Name   | Phone  |
+--------+--------+
| Name2  | Phone2 |
+--------+--------+
...

I would like to do the following:

+-------+-------+-------+-------+
| Name  | Name1 | Name2 | Name3 |
| Phone | Phone1| Phone2| Phone3|
+-------+-------+-------+-------+
| Name4 | Name5 | Name6 | Name7 |
| Phone4| Phone5| Phone6| Phone7|
+-------+-------+-------+-------+

Does this make sense?

My code does not work:

<table border="0"> <TMPL_LOOP NAME="PHONE_LOOP"> <tr> <td> <TMPL_VAR NAME="NAME"> <br> <TMPL_VAR NAME="PHONE"> </td> <td> <TMPL_VAR NAME="NAME"> <br> <TMPL_VAR NAME="PHONE"> </td><td> <TMPL_VAR NAME="NAME"> <br> <TMPL_VAR NAME="PHONE"> </td><td> <TMPL_VAR NAME="NAME"> <br> <TMPL_VAR NAME="PHONE"> </td> </tr> </TMPL_LOOP> </table>

This, of course, just repeats the same pair of variables four times in the row, instead of getting the first four sets. I know I could create the rows in the Perl script, but the idea of the HTML::Template would be that I could tweak the template to adjust how many columns.

Any help, pointers, docs would be very helpful. Thanks


In reply to Column Count w/ HTML::Template by dejoha

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.