Click Here!
Click Here!

Perl Primer Eight Assignment
A Possible Answer

     The fairly easy part is getting the display to show when two conditions are met. the hard part, I would assume, was what to do if the conditions were not met. You don't want anything printed. Well, then don't print anything. See below. My changes are in bold.


($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = localtime(time);
$thishour = (0,1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11,12) [(localtime) [2]];
$thismonth = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[(localtime)[4]];
$thisday = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday)[(localtime)[6]];

print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>Thank You!</TITLE>\n";
print "</HEAD>\n";
print "Today is $thisday, $thismonth, $mday, 200";
print $year-100;
print ", $thishour:$min:$sec ";

if($hour > 11 && $hour < 18)
{print " PM. Good Afternoon.";}
elsif($hour > 17 && $hour < 24)
{print "PM. Good Evening.";}
{print "AM. Good Morning.";}

if($hour > 5 && $min > 30)
{print "<P>It is after 6:30. Get some dinner";}
{print "";}

print "<P>";

print "Day of the week: $wday<P>Day of the year: $yday";

print "</BODY>\n";
print "</HTML>\n";

Close this window to return to the Primer