Please send questions to st10@humboldt.edu .
#!/local/bin/perl -w

#######################################################
# lect14_template1.pl
#
# trying out the HTML::Template module
#    using the "special" perl path /local/bin/perl,
#    where HTML::Template has been installed ON SORREL
#
# Adapted from "Practical Perl with CGI Applications",
#    Chang, Scott/Jones Publishing, p. 357
#
# adapted by Sharon Tuttle
#
# last modified: 11-30-04
#######################################################

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 => 'lect14_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 lect14_template1.pl