separator

Take a quiz or make one of your own
The Program:

#!/usr/local/bin/perl
#
# Webpage Hit Counter
#
# Program02 in a series of CGI/Perl Tutorials on
# http://www.thecgibin.com/
# Author : Marty Landman Email : cgiperl@thecgibin.com
#
# You may use and distribute this freely as long as you agree
#
# 1) not to hold Face 2 Interface Inc. or Marty Landman
# responsible for the results of using this software
# 2) to keep these comments intact
#

print "Content-type: text/html\n\n";
print 'cannot open count : ',$! # ready count file
if not open (COUNT, '+flock(COUNT, 2); # execute system file lock cmd
my $counter = ; # read current count value
$counter++; # bump count value by one
seek (COUNT, 0, 0) or print $!; # prepare for output
print COUNT $counter; # set count file to new value
flock(COUNT, 8); # unlock the count file
print 'cannot close count : ',$!
if not close (COUNT); # done working with count file

__END__

separator

© www.thecgibin.com