You are looking at a very old, but free version of the course. If you are interesed the most recent version, check it out on the Perl Maven site.

15.12. Generate web page

We are building the HTML pages from a template utilizing the HTML::Template module from CPAN. Besides the plain HTML the template has additional TMPL_* tags that will be filled by the values by HTML::Template.

Example 15-14. examples/applications/html.tmpl

<html>
<head>
</head>
<body>

<TMPL_IF echo>
  You typed <TMPL_VAR echo>
</TMPL_IF>

<form>
   <input name="text">
   <input type=submit" value="Echo">
</form>

</body>
</html>

This is a simple Perl script that should be installed to a CGIExec enabled directory of Apache. When the user hits this page the first time it displays a white page with only entry-box and a submit button on it. the user can fill the box,

Example 15-15. examples/applications/html.pl

#!/usr/bin/perl
use strict;
use warnings;

use CGI;
use HTML::Template;

my $template = HTML::Template->new(filename => "examples/html.tmpl");
my $q = CGI->new;
print $q->header;


if ($q->param("text")) {
    my $text = $q->param("text");
    $template->param(echo => $text);
}
print $template->output

If you are interested in on-site trainings by the author, please contact me directly.