Hello,
I'm writing a script that uses HTML::Template for the first time and
I've run into a problem that has me stumped. I'm probably missing
something that's right in front of me, but if anyone could point out my
error or suggest debugging techniques that I can use, I'd be much
obliged.
I have a script that takes data and attempts to insert them into an HTML
template. I'm using a TMPL_LOOP tag to iterate over an html table with a
few TMPL_VAR tags in each cell. The relevant part of the template is:
<table width="75%" border="1">
<tr>
<td class="bodyCopy">Organization</td>
<td class="bodyCopy">Recruitment Activity</td>
</tr>
<TMPL_LOOP NAME=FIRM_ROW>
<tr>
<td> <TMPL_VAR NAME=ANCHOR> <TMPL_VAR
NAME=FIRM_NAME></td>
<td> <TMPL_VAR NAME=FIRM_ACT></td>
</tr>
</TMPL_LOOP>
</table>
I'm pretty sure this is correct. But when I run the following
subroutine, I can't get the parameters to pass properly and my script
dies!
while (@name_links and @activities and @names) {
my %row_data; # get a fresh hash for the row data
# fill in this row
$row_data{FIRM_NAME} = shift @name_links;
$row_data{FIRM_ACT} = shift @activities;
my $letter = shift @names;
$letter = substr( $letter, 0, 1 );
unless (exists $letters{$letter}) {
$letters{$letter} = ();
$row_data{ANCHOR} = "<A name= $letter ></A>";
}
# the crucial step - push a reference to this row into the loop!
push(@loop_data, \%row_data);
}
$template->param(firm_row => \@loop_data) or die "Parameters not passed
to loop: $!\n";
print FIRM $template->output() or die "Unable to print output!";
This code was adapted from the POD for HTML::Template, so I'm a little
surprised it doesn't work. So, am I just missing something obvious
here? If not, can anyone suggest any debugging techniques that will
show me what is causing the parameters to fail?
Thanks,
Alan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]