This don't work:
[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.
EDIT

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:

(name this 'params.tmpl') <TMPL_IF PARAMS> <table> <tr> <tH>KEY</th> <th>&nbsp;</th> <th>VALUE</th> </tr> <TMPL_LOOP NAME=PARAMS> <tr> <td align="right"><TMPL_VAR NAME=KEY></td> <td align="center">=&gt;</td> <td><TMPL_VAR NAME=VALUE></td> </tr> </TMPL_LOOP> </table> <TMPL_ELSE> No params! </TMPL_IF>
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.

The CGI script (params.cgi):

use 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;
You can test this out by pointing any HTML form to the cgi script, or you can test it directly (YMMWV):
http://localhost/cgi-bin/params.cgi?foo=bar&qux=baz&foo=bar2 http://localhost/cgi-bin/params.cgi

jeffa


In reply to (jeffa) 2Re: HTML::Template Help by jeffa
in thread HTML::Template Help by Mr.T

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.