$template->param( warnings => \@warning ) || die $!;
Update:#!/usr/bin/perl use strict; use HTML::Template; use MIME::Lite; use CGI; use CGI::Carp qw/fatalsToBrowser/; use Data::Dumper; my $c = new CGI; validate( qw/ email phone/ ); my $c = new CGI; print $c->header,$c->start_html('everythings ok'); sub validate { my $c = new CGI; my @params = @_; my @warning; for ( @params ) { push (@warning, { 'missing' => $_ }) unless $c->param($_); } if ( @warning ) { print $c->header; my $template = HTML::Template->new(filename => './templates/warnin +g.html'); $template->param( warnings => \@warning ) || die $!; $template->output() || die $!; print Dumper @warning; exit; } }
Content-type: text/html Software error: Died at /var/www/cgi-bin/ebranch/assignment/process.cgi line 28. For help, please send mail to the webmaster (root@localhost), giving t +his error message and the time and date of the error.
<span class="bigText"> Warning! The following fields are missing.< +/span> <TMPL_LOOP warnings> <TMPL_VAR missing><br /> </TMPL_LOOP>
In reply to Error when passing AoH ref to HTML::Template by silent11
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |