First, like all non-standard Perl modules, you will need to install HTML::Template from CPAN, and then you can include it at the top of your Perl programs with the use statement:
use HTML::Template;Before we can get to the Perl part of our program, we'll need to create a template to use in it. A template is a plain, old HTML file, but when we save it, we'll call it my_page.tmpl:
<html>Now we're ready to use this template in our Perl scripts by pointing it at the file:
<head><title>My Template Page</title></head>
<body>
<h1>My Template Page</h1>
<p>Hello, <TMPL_VAR NAME=USERNAME>, this is a template.</p>
</body>
</html>
my $tpl = HTML::Template->new(filename => 'my_page.tmpl');Then we can mark the template tags that we want to replace with our data (TMPL_VAR NAME) and fill it in via the script:
$tpl->param(USERNAME => 'About.com User');And finally print the HTML header and the page itself:
print "Content-Type: text/html\n\n", $tpl->output;Module Links:
