Catman...erator(3pm)
π Catmandu::Iterator β the manual page, but make it cute π
okay bestie, so you've stumbled into Catman...erator(3pm) β yes that's the page title, it's giving β¨user contributed Perl documentationβ¨ energy, and it's literally all about Catmandu::Iterator, the base class for all Catmandu iterators π. It's a 3pm page, so it's Perl module docs, and honestly? iconic. periodt.
πΈ NAME πΈ
Catmandu::Iterator β the base class for all Catmandu iterators π
Like, every iterator in Catmandu-land descends from this thing. It's the blueprint. The mother of iterators. The moment. π¦
β¨ SYNOPSIS β¨
Here's the vibe, copied exactly because code is sacred and I do not play with it:
package My::MockIterator;
use Catmandu;
use Moo;
with 'Catmandu::Iterable';
sub generator {
sub {
# Generator some random data
+{ random => rand };
}
}
package main;
my $it = My::MockIterator->new;
my $first = $it->first;
$it->each(sub {
my $item = shift;
print $item->{random} , "\n";
});
my $it2 = $it->map(sub { shift->{random} * 2 });
So what's happening here, bestie? You roll your own class, you pull in Catmandu and Moo, you with 'Catmandu::Iterable' (that's the role doing the heavy lifting, iykyk), and then you define a generator that hands back a closure. That closure spits out one Perl hash at a time. Then ->new gives you an iterator, ->first grabs you the first item, ->each walks the whole thing and prints each random value, and ->map gives you a whole new iterator where every random got doubled. π₯
π METHODS π
π§ generator
Should return a closure that generates one Perl hash. That's it. That's the whole job. One hash per call, over and over, like a little hash vending machine. π
fr fr, if you don't give it a generator that returns a closure, the magic does not happen. no generator, no slay.
π INHERIT π
Okay so here's the tea: if you provide a generator, then the class will generator all methods from Catmandu::Iterable. (Yes, that's what the original says β "generator" as a verb. We respect the original's grammar choices in this house. π)
Translation: you bring the one tiny generator, and Catmandu::Iterable shows up with the entire method catalogue. Main character energy from a two-line subclass. π
π SEE ALSO π
Catmandu::Iterableβ go read this one next, bestie, it's literally where all the inherited methods live π«Ά
and that's the whole page!! no cap, every single detail is in here, I did not skip a single crumb π
cute lil sign-off: this page ships as part of perl v5.40.1, dated 2026-01-24, and it was written for User Contributed Perl Documentation β aka the people's docs, the community's finest. πβ¨ππ¦πΈπ πβπ
π¦ 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