#!/usr/bin/perl use strict; # Change this variable to where you want # your count files to be. my $dir = "counter"; my ($id,$nr) = split(/=/, $ENV{'QUERY_STRING'}); $nr = ($nr/$nr==1)? $id : die; my $file = "$dir$nr.txt"; # Read count open(FILE, "< $file"); my $count = ; # Increment count open(FILE, "> $file") || die "Can't open $file: $!\n"; print FILE ++$count; print "Content-type: text/plain\n\ncount=$count"; exit;