Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Error when passing AoH ref to HTML::Template

by eric256 (Parson)
on Aug 18, 2005 at 16:30 UTC ( [id://484862]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Error when passing AoH ref to HTML::Template
in thread Error when passing AoH ref to HTML::Template

Only create one $c. Then pass it to validate. CGI can get tempermental when you keep creating new ones.

#!/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($c, qw/ email phone/ ); print $c->header,$c->start_html('everythings ok'); sub validate { my $c = shift; 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 ); print $template->output(); print Dumper @warning; exit; } }

___________
Eric Hodges

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://484862]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (7)
As of 2024-03-29 15:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found