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?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|