#!perl -w # counter script increments and prints value in $file # set permissions to allow script to read and write $file - epoptai use strict; my$file = 'count.txt'; open (FILE,"+>> $file") or die "$!"; # open file unless($^O=~/mswin/i){ flock(FILE,2) or die "$!"} # lock unless win32 local $/ = undef; my$num = ; # read file into array $num++; seek FILE, 0, 0; # goto top of file truncate FILE, 0; # and clear it print FILE $num; # write modified contents close FILE or die "$!"; print $num; # print incremented value