#!/usr/local/bin/perl require "stat.pl"; require "ctime.pl"; # This perl script counts accesses to a file foo.html and prints # the last modified date for that file. Set the variable $file # to the complete path of the file whose accesses you want to count. # $countfile is a file which will contain the current count. The complete # filename must be given for it too. A careful version of this script # would do file locking since multiple processes might be trying to # update $countfile simultaneously. Note that the WN user id (usually # "nobody") must have write permission for this file. $countfile = "/usr/local/wn/wn_root/services/elm/elm.count"; $file = "/usr/local/wn/wn_root/services/elm/elm.html"; &Stat( $file); open( COUNT, "<$countfile" ) || die "Can't open file: $! for reading"; $count = ; close( COUNT); $count++; print "Number of times this page has been served: ", $count, "
\n"; print "Stolen: ", &ctime($st_mtime), "\n"; open( COUNT, ">$countfile" ) || die "Can't open file: $! for writing"; print COUNT $count, "\n"; close (COUNT);