I just picked this up a few weeks ago, myself. I am enjoying it very much, it is so simple and elegant. I hope this is something you were looking for. Below is the skeleton of the program I worked out. (And as always, suggestions appreciated, as well)
#!/usr/bin/perl -w use CGI qw(:standard); use HTML::Template; use strict; my $output = new CGI; my $baseDir = "/home/projects/scripts/devsimp"; my @names = $output->param; @INC = ('../cgi-lib', '/usr/lib/perl5/site_perl', '/usr/lib/perl5/5.00503'); require 'cgi-lib.pl'; ### $inputlist Gets all the stuff from the form. my $inputlist = &get_form_input(); &show_browser_output(); exit 0; sub show_browser_output { ### Based on, basically which section and what page number, ### $templatename gets the appropriate template to use for output my $templatename = &get_template(); my $a = ""; my $b = ""; ### %params gets the parts to fill in the blanks in the template ### my %params = &get_params(); my $template = HTML::Template->new(filename => "$baseDir/templates/$ +templatename"); print "Content-type: text/html\n\n"; while (($a, $b) = each(%params)) { $template->param( $a => $b ); } print $template->output; } ### Determines template to use based on subset of the form values' nam +es. ### sub get_template { ###Code to determine which template to use ### return $template; } ### Get the parts to fill in the blanks in the template ### sub get_params { my %param = (); my $page_header = ""; my $page_paragraph = ""; my $page_questions = ""; my $curr_page = $page_num; my $new_page_num = ""; ####Code to fill up the parameters that are going to be displayed ### %param = ( CAT => "$shorthand{$startingcat}", HEADER => "$page_header", PARAGRAPH => "$page_paragraph", PAGE => $new_page_num, QUESTIONS => "$page_questions", TEST_TEXT => $names[0], TEST_TEXT1 => $names[1], TEST_TEXT2 => $names[2] ); return %param; } ### Gets names of every form field submitted. ### sub get_form_input { my $listofparams = ""; my $c = ""; my @input = ""; foreach $c (@names) { $listofparams .= "$c, "; } return $listofparams; }

In reply to Re: HTML::Template Help by Valkerri
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.