in reply to Safe Counter Follow Up
in thread Safe Counter

open(MFILE, ">$completeadd") || die "file open failed: $!\n"; flock(MFILE, LOCK_EX) || die "Lock failed: $!";
Yup, that's the culprit. You are zeroing the file before obtaining the flock, thus possibly stomping on someone else's read or write.

Either use File::CounterFile, or read my columns that use flock for working examples.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.