Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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

by silent11 (Vicar)
on Aug 17, 2005 at 20:03 UTC ( #484570=note: print w/replies, xml ) Need Help??

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

Thanks! I'll give your code a try.

I didn't want to add the extra instance of CGI, but when I don't add the instance inside of the sub I get the following eror:

Can't call method "param" on an undefined value at /var/www/cgi-bin/eb +ranch/assignment/process.cgi line 23.
Any ideas?

Spread Firefox

Replies are listed 'Best First'.
Re^3: Error when passing AoH ref to HTML::Template
by eric256 (Parson) on Aug 18, 2005 at 16:30 UTC

    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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://484570]
[stevieb]: The people back then (~2000) are the same people now, but with much more experience. I'm appreciative that I fell into the Perl rabbit hole.
[stevieb]: Coding circles around Python devs, showing how unit tests should be done, enabling easy access to everything, learning basic C to wrap for direct hardware access... I am thankful.
[stevieb]: I'm in an appreciative mood. Thank you fellow Monks, for all I know, and for the knowledge which I can pass on

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2017-02-25 01:26 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (364 votes). Check out past polls.