in reply to Re: Opening a file for reading or writing (was: Newbie)
in thread Opening a file for reading or writing (was: Newbie)

First of all useful error messages should always preserve whatever information you can get on what went wrong. In this case that means you shouldn't lose the filename and contents of $!.

Secondly your file locking makes all of the usual mistakes and will be subject to all of the regular race conditions. You need to put your locks around the entire sequence of actions that should be an atomic unit. There have been several threads on this before, see Re (tilly) 1: Flock Feedback for an example.

  • Comment on Re (tilly) 2: Opening a file for reading or writing (was: Newbie)