logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Catmandu::Counter - A Base class for modules who need to count things

Attributes

count
       The current value of the counter.

Methods

inc_count()inc_count(NUMBER)
       Increment the counter.

   dec_count()dec_count(NUMBER)
       Decrement the counter.

   reset_count()
       Reset the counter to zero.

Name

       Catmandu::Counter - A Base class for modules who need to count things

See Also

       Catmandu::Exporter

perl v5.40.0                                       2025-01-17                             Catmandu::Counter(3pm)

Synopsis

           package MyPackage;

           use Moo;

           with 'Catmandu::Counter';

           sub calculate {
               my ($self) = @_;
               $self->inc_count;
               #...do stuff
           }

           package main;

           my $x = MyPackage->new;

           $x->calculate;
           $x->calculate;
           $x->calculate;

           print "Executed calculate %d times\n" , $x->count;

See Also