Please send questions to
st10@humboldt.edu .
#!/usr/bin/perl -w
#######################################################
# lect13_template1.pl
#
# trying out the HTML::Template module
# (also adding to @INC with pragma lib, because
# had to install
# this module "locally" --- beware, and change
# that path as needed!!)
#
# Adapted from "Practical Perl with CGI Applications",
# Chang, Scott/Jones Publishing, p. 357
#
# adapted by Sharon Tuttle
#
# last modified: 11-16-04
#######################################################
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# WARNING --- change to YOUR appropriate path!!!
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
use lib '/home/faculty/st10/perllib';
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser warningsToBrowser carpout);
use HTML::Template;
warningsToBrowser(1); # activate warnings
# "create a nwe template object that is associated with a
# template source", [Chang, p. 354]
my $page_templ = HTML::Template->new(
filename => 'lect13_template1.tpl');
# set up today's date
# the RHS here is an ARRAY SLICE --- @arr[3, 4, 5] is an
# array with 3 elements, the 4th, 5th, and 6th from
# @arr
# (see "Learning Perl" pp. 244-245 for more on array slices)
#
# (localtime() must return the current time information in an
# array with at least 6 elements them, hmm?)
my ($monthday, $month, $year) = (localtime())[3, 4, 5];
$year += 1900;
my @months= qw(January February March April May
June July August September October
November December);
# "Specify what will be filled into the template
# variables" [Chang, p. 356]
$page_templ->param(what => 'an example',
date => "$months[$month] $monthday, $year",
message => 'Love those templates'
);
# output result to browser
print header, "\n";
print $page_templ->output;
# end lect13_template1.pl