If you just want a simple incrementing counter, one way to do this is to use the size of the file as the counter, rather than its contents. You don't need locking to do this:
my $filename = '/path/to/file'; # Increment the counter (atomically, so no locking required) open(FILE, ">> $filename") or warn "Missed a count"; print FILE '.' # Ouput one (arbitrary) byte close FILE; # What is the counter set to? my $countval = -s $filename || 0;
The disadvantage of this technique is that it uses one byte of disk space for each count.
In reply to Re: Re: Flock Feedback
by tomhukins
in thread Flock Feedback
by footpad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |