Catman...Counter(3pm)

๐Ÿ“ฆ
version 1.2025 ยท 4 versions
, in ubuntu resolute, ubuntu stonking

๐Ÿ’– Catman...Counter(3pm) ๐Ÿ’–

okay bestie, gather round, because we're talking about Catmandu::Counter โ€” it's a base class for modules who need to count things ๐Ÿงฎโœจ like, it's the little counter goblin that other modules inherit from when they need to keep track of how many times stuff happened. no cap.


โœจ NAME โœจ

Catmandu::Counter โ€” a Base class for modules who need to count things ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

here's the whole vibe, verbatim, no notes:

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;

so you use Moo, you with 'Catmandu::Counter', and suddenly your package has a counter. you call $self->inc_count inside your method, run it three times, and $x->count tells you it ran 3 times. it's giving main character energy for the tiniest possible job and honestly? obsessed. ๐Ÿซถ


๐ŸŽ€ ATTRIBUTES ๐ŸŽ€

count

the current value of the counter. that's it, that's the whole attribute. it's just... the number rn. ๐Ÿ’ซ


๐Ÿ’… METHODS ๐Ÿ’…

inc_count() / inc_count(NUMBER)

increment the counter. โฌ†๏ธ๐Ÿ”ฅ pass it a NUMBER and it goes up by that much; call it with nothing and it just goes up by its default amount. slay.

dec_count() / dec_count(NUMBER)

decrement the counter. โฌ‡๏ธ๐Ÿ’€ same deal โ€” give it a NUMBER to go down by that much, or call it bare and let it do its default thing. the counter said "not today, we're going backwards."

reset_count()

reset the counter to zero. ๐ŸŒˆ total factory reset for your number. new arc, new era, count starts at 0 again. periodt. ๐Ÿ‘‘


๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

  • Catmandu::Exporter โ€” go look at this one too, iykyk ๐Ÿ’œ

๐Ÿ’– reminder bestie: this is the Catmandu::Counter page from the User Contributed Perl Documentation, and it's sitting in the Catman...Counter(3pm) section. fr fr.

and that's the whole page, we're done!! this one shipped with perl v5.40.1 and was dated 2026-01-24 โ€” so like, shoutout to perl v5.40.1 and to that date, mwah ๐Ÿ’‹โœจ bye bestie ๐Ÿฆ‹๐Ÿ’–๐ŸŒธ

๐Ÿ“ฆ where this page comes from