#!/usr/bin/perl -wT
useCGIqw(:standard);useCGI::Carpqw(warningsToBrowser fatalsToBrowser);usestrict;useFcntlqw(:flock :seek);printheader;# print the content-type headeropen(IN,"+<counts")or&dienice("Can't open counts for reading: $!");flock(IN,LOCK_EX);# lock the file (exclusive lock)seek(IN,0,SEEK_SET);# rewind it to the beginningmy$count = <IN>;# read only the first line.$count = $count + 1;# increment the counterseek(IN,0,SEEK_SET);# rewind it to the beginningprintIN"$count\n";# write out the new countclose(IN);# close the file.printqq(<p><img src="imgcount.cgi?$count"></p>\n);sub dienice{my($errmsg) = @_;print"<p>$errmsg</p>\n";exit;}