http://qs321.pair.com?node_id=11145527

logangha has asked for the wisdom of the Perl Monks concerning the following question:

I am using Template Toolkit to generate HTML code. It is used inside a loop. First time (first iteration) works ok, but next it does not do anything. Here it is Perl code

my $headers = HTTP::Headers->new; $headers->header('Content-Type' => 'text/html;charset=UTF-8'); print $headers->as_string; my $template = Template->new({ INCLUDE_PATH => some path, INTERPOLATE => 1, }) || do { my $error = $Template::ERROR; my $q = new CGI; error($q, "Caught error: " . $error); }; my $link = ""; foreach my $key (keys %referencesData) { $link = $referencesData{$key}; # Here it is where html is invoked and first iteration works ok, b +ut next it does not do anything $template->process('template.ttml', { link => $link } ) || do { my $error = $template->error(); my $q = new CGI; error($q, "Caught error: " . $error); }; }

And here it is ttml code

[%# template.ttml %] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <head> <TITLE>Some title</TITLE> <meta http-equiv="refresh" content="$link" /> </head> <body> <center> </center> <form action=""> </form> </body> </html>

As I mentioned, it works ok in first iteration, but next one it seems it does not do anything. What seems to be the trouble?