I would like some help with the following. I've done several Super Searches, read through lots of examples, but I'm still stumped (probably not seeing the forest for the trees). I receive an error message when trying to run my radio.pl program:

HTML::Template->output() : fatal error in loop output : HTML::Template : Attempt to set nonexistent parameter '6' - this parameter name doesn't match any declarations in the template file : (die_on_bad_params => 1) at /usr/local/lib/perl5.8.0/site_perl/HTML/Template.pm line 2905 at /local/www/htdocs/scripts/campus/radio.pl line 31

For the life of me, I can't figure out why it's not happy. I can add or subtract key/value pairs, and the error message line reference just moves up/down accordingly. Any help would be appreciated! (I've cut this example code down to a bare minimum; the original HTML code without TMPL_LOOP worked okay but was lengthy with lots of repetition. Given my customers' penchant for changing stuff, I like the idea of control tables so I have to make changes in only ONE place in my code). Thanks!

radio.pl

#!/usr/local/bin/perl5_8 use strict; use HTML::Template; $|=1; print "content-type: text/html\n\n"; my $template = HTML::Template->new( filename => 'radio.tmpl' ); ############################### Begin Section ###################### #Control table used to generate report radio buttons, rpt titles... #template vars: key->Rpt no. (rpt_no); value->Rpt Descr (rpt_descr) my %rpt_tbl = ( '1' => 'Fiscal Year-to-Date Financial Information' ,'2' => 'QTD/PTD Financial Information' ,'3' => 'Cash Balance' ,'4' => 'Financial Status' ,'5' => 'Financial Summary Status' ,'6' => 'Summary by Phase' ,'7' => 'Summary by Segment' ); my (@radio_loop, $key); foreach $key ( sort keys %rpt_tbl ) { $rpt_tbl{rpt_no} = $key; $rpt_tbl{rpt_descr} = $rpt_tbl{$key}; push(@radio_loop, \%rpt_tbl); } #+++++++++++++++++++++++++++++++ End Section ++++++++++++++++++++++++ $template->param(radio=>\@radio_loop); print $template->output();
radio.tmpl
<html> <head> <title>NCSU Campus Financials Reporting</title> <meta http-equiv="Pragma" content="no-cache"> <style type="text/css"> td.welc { font: bold 10pt "Arial"; color:black; text-align:le +ft; } </style> </head> <form name="frm_mainmenu" method="post" action="nc_rpt_summary.pl"> <table border="0" width="100%" summary="Input Form"> <tr> <td class=welc width="10%" rowspan="7" valign="top">Step 1:</td> <td class=welc width="20%" rowspan="7" valign="top">Select a Report</t +d> <td class=welc width="70%" id="rpt1form"> <TMPL_LOOP NAME=radio> <input type="RADIO" name="rpt_id" value="<TMPL_VAR NAME=rpt_no>_su +mm" onclick="1" onfocus='frm_mainmenu.rptname.value="Report <TMPL_VAR NAME= +rpt_no>";'> <span style="cursor:pointer;cursor:hand" onclick='window.open("../c2/descrs.html#Rpt<TMPL_VAR NAME=r +pt_no>Descr", "myWindow", "width=650,height=600,top=10,left=10,sc +rollbars=yes");'> &nbsp;&nbsp;Report <TMPL_VAR NAME=rpt_no> - <TMPL_VAR NAME= +rpt_descr> </span></td> <tr> <td class=welc> </TMPL_LOOP> &nbsp;</td></tr></table></form> </body></html>

Lori


In reply to HTML::Template, TMPL_LOOP problem by Lori713

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.