Catman...Counter(3pm)
๐ 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 theCatmandu::Counterpage from the User Contributed Perl Documentation, and it's sitting in theCatman...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
- ubuntu resolute: libcatmandu-perl 1.2025-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-perl 1.2025-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms