in reply to How do I lock a file in perl?

Have a look at perlfaq for locking files using flock() or how to lock a file 'manually'