Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
is there a simpler way to do this? I want something that will be generous enough to not lock up the entire program if it can't lock one file, but I also want it to be able to retry if someone else has it locked at the moment.FLOCK: do { open (FILE, ">file.dat"); flock(FILE, 2) or redo FLOCK; print FILE "blah\n"; close FILE; $locked = 1; } while ($locked =/ 1)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: flock till ya get it right
by merlyn (Sage) on Nov 04, 2001 at 02:21 UTC | |
|
Re: flock till ya get it right
by dws (Chancellor) on Nov 04, 2001 at 02:23 UTC |