#!/usr/bin/perl -w use strict; use HTML::Template; my $template = HTML::Template->new(filename => 'tipDisplay.tmpl'); print "Content-type: text/html\n\n"; my @tipList; open (IFS, "tips.txt"); # Put all of the tips into an array on hash references while () { push @tipList, { 'Tip' => $_ }; } close IFS; # Take the most recent tip out of the array my $tempHashRef = pop @tipList; my %tempHash = %{$tempHashRef}; my $recentTip = $tempHash{'Tip'}; # Supply the template with data $template->param( Archive => \@tipList, ArchiveExists => @tipList, RecentTip => $recentTip, ); print $template->output;