http://qs321.pair.com?node_id=495177


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...

my $count = File::CounterFile::Resettable->new("./asr_counter.txt"); $count->lock(); $count->reset(); $count->unlock();
(Code is untested, but you hopefully get the idea!)

    --k.


Update: $code =~ s/\t/ /g; # for readability.