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?


In reply to Doubt about Template Toolkit by logangha

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.