#!/usr/local/bin/perl

$base_dir = 	"/cgi-bin/";
$file_name = 	"count.txt";
$lock_file = 	"count_lock";

$lock_delay = 3;

# send content type to browser
print "Content-type: text/html\n\n";

if (!open(read_count, "$file_name")) {
	print "Error";
	die;
	}

else {
	flock(read_count, 2);
	$line = <read_count>;
	close(read_count);

	chop($line) if $line =~ /\n$/;

	($count) = split (/\|\|/, $line);
	$count++;
	print "$count";

	if (open (write_count, ">$file_name")) {
		flock(write_count, 2);
		print write_count "$count\|\|";
		close (write_count);
		}
	else {
		print "Error writing";
		}
#	$uri = $ENV{'REMOTE_ADDR'};

#	$print "$uri";
	
	}
end;
