in reply to File I/O

The Perl FAQ 5 page contains the definitive answer at "I still don't get locking. I just want to increment the number in the file. How can I do this?".

Another approach would be to use File::CounterFile.