in reply to Re: Flock Feedback
in thread Flock Feedback
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Flock Feedback
by chipmunk (Parson) on Feb 26, 2001 at 20:04 UTC | |
by tye (Sage) on Feb 26, 2001 at 20:57 UTC |