I'm struggling with a <TMP_LOOP> problem ...
Using a subroutine call:
if ( $q->param('action') eq 'one') { CallSubroutine('Red'); }
I send a "select" call to a MySql table. The subroutine call includes a value that determines what records are returned. I "grab" what the select call returns using:
my $res = $sth->fetchall_arrayref({});
...................
assign it to a parameter:
$q->param(res => $res);
...................
call the template using "associate"
my $template = HTML::Template->new( filename => 'template_filename.tmpl', associate => $q, );
..................
write the template content to a file
open (FILE,">$filename") or die "no $filname!\n"; $template->output(print_to => *FILE); close(FILE);
..................
the template looks like:
<TMPL_LOOP res> All kinds of HTML stuff here, including <TMPL_VAR NAME=whatever> values </TMPL_LOOP>
........................
The above works fine. The problem I'm having is when I call the subroutine twice - each time sending a different value:
if ( $q->param('action') eq 'two') { CallSubroutine('Red'); CallSubroutine('Blue'); }
The output is written to the correct two files, *but* the content of the files is identical, and always matches the content of the first iteration of the subroutine:
if ( $q->param('action') eq 'two') { CallSubroutine('Red'); CallSubroutine('Blue'); }
produces two identical files with the "Red" content
if ( $q->param('action') eq 'two') { CallSubroutine('Blue'); CallSubroutine('Red'); }
produces two identical files with the "Blue" content. It appears that the template "storing" the first loop content, and not letting it go when the subroutine is called the second time.
I'm an H::T newbie ... maybe there's something obvious I'm missing?
Carl Hagstrom
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users