note
Kanji
<p>You could extend F::CF to support zeroing out the counter.</p>
<p>Something like...</p>
<code>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
}</code>
<p>...and then later in your script...</p>
<code>my $count = File::CounterFile::Resettable->new("./asr_counter.txt");
$count->lock();
$count->reset();
$count->unlock();</code>
(Code is untested, but you hopefully get the idea!)
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-33345">
<p> --k.</p><br>
</div></div>
Update: $code =~ s/\t/ /g; # for readability.
495149
495149