HTML::Template Loop Issue
Shawn Scott <[email protected]> Thu, 8 Apr 2010 17:20:36 -0400
| Newsgroups | gmane.comp.lang.perl.modules.html-template |
|---|---|
| Message-ID | <[email protected]> |
--===============7876892781714567496==
Content-Type: multipart/alternative; boundary=001517576deeedf39d0483c03f11
--001517576deeedf39d0483c03f11
Content-Type: text/plain; charset=ISO-8859-1
Good Afternoon,
I have been using HTML::Template for some time and have recently run into an
starnge issue. I have the following code
my @error = @_;
my @error_loop = ();
my %error_data;
print header;
foreach (@error) {
$error_data{ERROR_DATA} = $_;
push(@error_loop, \%error_data);
}
my $template = HTML::Template->new(filename =>
"$html_root/signup_error.html");
$template->param(ERROR_LOOP => \@error_loop);
print $template->output;
When I run this code it gives me the correct number of elements, based on
the number of errors in the loop @error array. The only issue each one is
shown as the last line pushed to the @error_loop. If I change the code to
this
foreach (@error) {
print p"DEBUG - $_\n";
$error_data{ERROR_DATA} = $_;
push(@error_loop, \%error_data);
}
I get the correct vaules printing out in the debug print line but then the
actual template loop variables are wrong.
Any help would be great.
--001517576deeedf39d0483c03f11
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div>Good Afternoon,</div>
<div>=A0</div>
<div>I have been using HTML::Template for some time and have recently run i=
nto an starnge issue. I have the following code</div>
<div>=A0</div>
<div>my @error =3D @_;=A0 <br>=A0=A0my @error_loop =3D ();<br>=A0=A0my %err=
or_data;<br>=A0=A0print header;<br>=A0=A0foreach=A0 (@error) {<br>=A0=A0=A0=
=A0$error_data{ERROR_DATA} =3D $_;<br>=A0=A0=A0=A0push(@error_loop, \%error=
_data);<br>=A0=A0}<br>=A0=A0my $template =3D HTML::Template->new(filenam=
e =3D> "$html_root/signup_error.html");<br>
=A0=A0$template->param(ERROR_LOOP =3D> \@error_loop);<br>=A0=A0print =
$template->output;</div>
<div>=A0</div>
<div>When I run this code it gives me the correct number of elements, based=
on the number of errors in the loop @error array. The only issue each one =
is shown as the last line pushed to the @error_loop. If I change the code t=
o this</div>
<div>=A0</div>
<div>foreach=A0 (@error) {</div>
<div>=A0=A0=A0 print p"DEBUG - $_\n";<br>=A0=A0=A0=A0$error_data{=
ERROR_DATA} =3D $_;<br>=A0=A0=A0=A0push(@error_loop, \%error_data);<br>=A0=
=A0}<br></div>
<div>I get the correct vaules printing out in the debug print line but then=
the actual template loop variables are wrong.</div>
<div>=A0</div>
<div>Any help would be great.</div>
<div>=A0</div>
<div><br clear=3D"all"><br><br>=A0</div>
--001517576deeedf39d0483c03f11--
--===============7876892781714567496==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--===============7876892781714567496==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Html-template-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/html-template-users
--===============7876892781714567496==--