in reply to File::CounterFile problems : access from mulitple scripts and zeroing counter
You could extend F::CF to support zeroing out the counter.
Something like...
package File::CounterFile::Resettable; use base qw( File::CounterFile ); sub reset { my($self) = @_; if ($self->locked) { $self->{'value'} = 0; $self->{updated} = 1; } else { $self->lock; $self->{'value'} = 0; $self->{updated} = 1; $self->unlock; } $self->{'value'}; # return value }
...and then later in your script...
(Code is untested, but you hopefully get the idea!)my $count = File::CounterFile::Resettable->new("./asr_counter.txt"); $count->lock(); $count->reset(); $count->unlock();
--k.
|
---|
In Section
Seekers of Perl Wisdom