in reply to Re: HTML::Template Help
in thread HTML::Template Help
EDIT[jeffa@neo cgi-bin]$ perl -c val.cgi Global symbol "$template" requires explicit package name on line 51 Global symbol "$page_num" requires explicit package name on 64 Global symbol "%shorthand" requires explicit package name on line 71 Global symbol "$startingcat" requires explicit package name on line 71 val.cgi had compilation errors.
How about this instead - it is an ultra simple CGI script that merely displays the names and values of the parameters from any form. First the template:
It is a table with the names on in the left side cell and the values in the right. If no parameters are specified, then the <TMPL_IF> will take care of the fact and gracefully continue.(name this 'params.tmpl') <TMPL_IF PARAMS> <table> <tr> <tH>KEY</th> <th> </th> <th>VALUE</th> </tr> <TMPL_LOOP NAME=PARAMS> <tr> <td align="right"><TMPL_VAR NAME=KEY></td> <td align="center">=></td> <td><TMPL_VAR NAME=VALUE></td> </tr> </TMPL_LOOP> </table> <TMPL_ELSE> No params! </TMPL_IF>
The CGI script (params.cgi):
You can test this out by pointing any HTML form to the cgi script, or you can test it directly (YMuse CGI qw(:standard); use HTML::Template; use strict; my $template = HTML::Template->new(filename => 'params.tmpl') or die; my $params = [ map { { KEY => $_, VALUE => join(',',param($_)) } } param() ]; $template->param(PARAMS => $params); print header, start_html('Form Param Display'), $template->output, end_html;
http://localhost/cgi-bin/params.cgi?foo=bar&qux=baz&foo=bar2 http://localhost/cgi-bin/params.cgi
jeffa
|
|---|