1. "Hello, World!", simple
Before using HTML::Template, we will show a simple example to show the difference between using this module and not doing so.
#!/usr/bin/perl5
#### simple HTML Hello World
##usestrict;
my$that_famous_string = 'Hello, world!';
# send the obligatory Content-Type
print"Content-type: text/html\n\n";
# print the HTML
print'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">'."\n";
print"<html>\n";
print"<head>\n";
print"<title>$that_famous_string</title>\n";
print"</head>\n";
print"<body>\n";
print"<b>$that_famous_string</b>\n";
print"</body>\n";
print"</html>\n";
Run the script from the command line:
# perl -w helloworld.simple.pl
or in your browser (don't forget to configure DNS and Apache first):
Straightforward.
But what about web page design? We can't expect a web designer to be a Perl programmer as well.
And even if you don't care about design, the code already looks tough to maintain, with only one line of output.