perlquestion
atcroft
<p>My fellow and esteemed Monks, I come to thee penitent, in search of wisdom and guidance.<br>
<p><b>Background</b>: While I have tried to become a better Monk and user of perl in general, I have harbored a dark, embarassing secret sin in my coding, which I must now confess: Only recently have I begun to take my first faltering steps in learning to use a CPAN-available templating system. To my shame, I have generally embedded the HTML of many of my CGI scripts internally, either with print statements or, recently, with HERE documents, and only once did I venture so far into the darkness as to write my own simplistic attempt at a templating system. Once I learned about the available templating systems, and was able to get one of them installed on the system on which most of those CGIs run, it was my goal to someday go back and recode those still in use to use templates, so as to ease their maintenence.
<p>"Someday" has now become now, as I have been asked to modify the "look and feel" of the scripts in order to make them more closely match that of the rest of the systems in use. While most of them involve minor changes that can wait, a "due date" has been set on about a dozen of the worst offenders (in terms of radically different appearance). These dozen or so happen to be some of the oldest of the CGIs, so it seemed logical to attempt to migrate them to templates for the future. I have now run into a problem, which I seek your guidance on.<br>
<p><b>Problem</b>: Several of the scripts display data in an almost condensed form in tables, which I do not know how to replicate using [cpan://HTML::Template]. A simplified example-I may have returned a dozen or so values to display, and display them four to a line, so I may be returned (1, 3, 4, 6, 7, 8, 10, 12, 13, 14, 15, 19, 23, for instance) and need to display them as:<br>
<div align="center">
<table border="1">
<tr><td>1</td><td>3</td><td>4</td><td>6</td></tr>
<tr><td>7</td><td>8</td><td>10</td><td>12</td></tr>
<tr><td>13</td><td>14</td><td>15</td><td>19</td></tr>
<tr><td>23</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
</table>
</div>
<p>My question is, do I have to do something in the code to do this, or is there a way in [cpan://HTML::Template] that I can have it only display the number of items per line I need (it would be a fixed number for that page, if that makes it easier)? Would embedded loops or included templates do this, or would they be more complicated than necessary?
<p>I am truly outside of my knowledge range at the moment as I try to learn to do this, and to learn to be a better coder. Your attention and wisdom are greatly appreciated.