#!/usr/bin/perl # Lab 1: CGI Digital Clock # This script prints the current time to a web page. # Your assignment is to modify the script so that: # (1) the web page automatically refreshes every 5 seconds # (2) it checks the HTTP_USER_AGENT environment variable # and warns the user if it is not going to refresh itself @DAYS = qw( Sunday Monday Tuesday Wednesday Thursday Friday Saturday ); @MONTHS = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); $timeInSeconds = time; $intervalInSeconds = 5; # This is the number of seconds to wait for expire &printHeader; &printTime; sub printHeader { print "Content-type: text/plain\n\n"; } sub printTime { my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($timeInSeconds); print "The current time and date is:\n"; print "$DAYS[$wday], $mday-$MONTHS[$mon]-$year $hour:$min:$sec PST"; }