in reply to What is the best way to lock a counter file?
so my code looks something like this:
my $cntr="counterfile"; my $owncntr="counter.mine"; while (! rename $cntr,$owncntr) { # sleep some time to retry # or die if no more retries allowed } # do some work on file $owncntr if (! rename $owncntr,$cntr ) die "Someone created a new $cntr file?";
|
|---|