#!/usr/bin/perl
#### HTML template Hello World
##usestrict;
useHTML::Template;
my$that_famous_string = 'Hello, world!';
# open the html template
my$template = HTML::Template->new(filename => 'helloworld.tmpl.html');
# fill in some parameters
$template->param(THAT_FAMOUS_STRING => $that_famous_string);
# send the obligatory Content-Type
print"Content-type: text/html\n\n";
# print the template
print $template->output;
Run the script from the command line:
# perl -w helloworld.tmpl.pl
or in your browser (don't forget to configure DNS and Apache first):
Two files instead of one. And the same output as the previous example. So what's the deal?
Well, now you can pass "helloworld.tmpl.html" to your web designer to modify it in her/his favorite HTML editor.
(Just tell her/him not to touch the HTML tags starting with "<TMPL_".)
To redesign yor application's look, you don't have to modify your code at all.
A redesigned template using the same Perl code as above can look like this.