On Thu, 8 Apr 2010 17:20:36 -0400, Shawn Scott wrote > 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;
Each entry in your @error_loop is looking by reference at the %error_data hash key ERROR_DATA. So you are not storing the actual data in @error_loop, just a reference to the ERROR_DATA hash key in %error_data. That hash key takes the last value of the @error_loop during the foreach - and then all the references pointing to that key look the same. You are using a lot of variables, sigils, metacharacters, and capitalization that you don't need. It makes the code hard to read. It could be cleaner: my @errors = @_; my $template = HTML::Template->new(filename => "errors.html"); $template->param ( errorloop => [ map { { error => $_ } } @errors ], ); print header(); print $template->output; untested. HTH, Alex ------------------------------------------------------------------------------ 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 _______________________________________________ Html-template-users mailing list Html-template-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/html-template-users