#!/usr/bin/perl -w use strict; $\ = "\n"; # assume we're running in CGI mode if ... # ... the SERVER_PORT environment variable is set and 80 # (80 is the usual HTTP post) print "Content-Type: text/plain; charset=ISO-8859-1\n" if defined $ENV{SERVER_PORT} and "80" eq $ENV{SERVER_PORT}; my $file = "/users/faculty/jamie/public_html/course/CS/4173/"; my $mtime = (stat($file))[9]; print "\$file is `$file'"; print "\$file is the location of the course homepage on the server"; print "The course homepage was last modifed at ", scalar localtime $mtime, "\n\n"; print "stat \$file will return a list of information about the file \$file"; print " (stat \$file)[9] is the tenth element of the list"; print " (stat \$file)[9] is the mtime (modification time) of the file"; print " the mtime is the number of seconds since the Unix epoch (in 1970)"; print " (stat $file)[9] is ", (stat $file)[9], "\n"; print "localtime((stat \$file)[9]) will return a list of time data"; print " for example (localtime((stat \$file)[9]))[2] is the hour"; my $hour = (localtime((stat $file)[9]))[2]; print " (localtime((stat $file)[9]))[2] is $hour "; print " hour $hour is better known as ", hname($hour), "\n"; print "scalar localtime(...) will return the date as a string ", "instead of as a list"; print " scalar (localtime((stat \$file)[9])) is ", scalar localtime((stat $file)[9]); # - - - main ends / subroutine begins - - - # sub hname { my $hour = $_[0]; return "midnight" if 0 == $hour; return "noon" if 12 == $hour; return "$hour a.m." if $hour < 12; $hour -= 12; return "$hour p.m."; } # hname() ## EOF ##