#!/usr/bin/perl $LOCK_SH = 1; $LOCK_EX = 2; $LOCK_NB = 4; $LOCK_UN = 8; sub lock { flock (LOCKFILE,$LOCK_EX); seek (LOCKFILE,0,2); } sub unlock { flock (LOCKFILE,$LOCK_UN) ; } print "Content-type: text/shtml\n\n"; open (LOCKFILE,"<_count_lock"); # open lock file lock; # lock file open (GETCOUNT,"; # assign contents of file to $counter close (GETCOUNT); # close access to file $counter++; # increase $counter by 1. print "

"; print "$counter"; # print number of hits to users screen print "

"; open (PUTCOUNT,">count.log"); # open count log for output print PUTCOUNT ($counter); # replace old counter value with new one close PUTCOUNT; # close access to file unlock; # unlock file close LOCKFILE; # close lock file