Note that you can also simply place your template code into the DATA file (which begins with the token "__END__" or "__DATA__" at the end of your script), loading it with the filehandle parameter to HTML::Template::new() instead of the filename parameter. I like to use this technique for very simple scripts/short templates, as it keeps your HTML in the same physical file but separate from your Perl program:
#!/usr/bin/perl use strict; use warnings; use HTML::Template; my $tmpl = HTML::Template->new( filehandle => \*DATA ); my $user = 'Mr. Foo'; if (1) { $tmpl->param( message => "Hello $user, your account - ready" ); print $tmpl->output(); exit 0; } else { $tmpl->param( message => "Your user/pin incorrect - Use correct in +put" ); print $tmpl->output(); } __END__ Content-type:text/html <html> <head> <title>Account/title> </head> <body> <h2><TMPL_VAR message /></h2> </body> </html>
Hope this helps!
In reply to Re^2: perl if statement
by 1nickt
in thread perl if statement
by Drsin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |