#!/usr/bin/perl use strict; # Should always use this use HTML::Template; # Loads the HTML::Template module my $template = HTML::Template->new(filename=>"htmlbackground.tmpl"); my $hour = (localtime)[3]; my $bgcolor; if($hour < 12) { $bgcolor = "#00ff00"; # Green for the morning } elsif($hour == 12) { $bgcolor = "#0000ff"; # blue for noon } else { $bgcolor = "#ff0000"; # red for afternoon } # Set the template's variables to the varibles in the script $template->param(bgcolor=>$bgcolor); #Print the template out print "Content-type:text/html\n\n"; print $template->output(); exit;