Catman...terator(3pm)
π Catmandu::ArrayIterator π
okay bestie, gather round β this is the manual page for Catmandu::ArrayIterator, straight outta the User Contributed Perl Documentation. She's a Perl module (that's the (3pm) energy) and she has one job, and she does it flawlessly. π«Ά
β¨ NAME β¨
Catmandu::ArrayIterator β literally just converts an arrayref into an Iterable object. That's the whole thing. No cap. π
πΈ SYNOPSIS πΈ
Here's the vibe in code, copy-paste it, don't @ me:
use Catmandu::ArrayIterator;
my $it = Catmandu::ArrayIterator->new([{n => 1}, {n => 2}, {n => 3}]);
$it->each( sub {
my $item = $_[0];
# Very complicated routine
...
});
$it->[0];
# => {n => 1}
$it->first;
# => {n => 1}
$it->map(sub { $_[0]->{n} + 1 })->to_array;
# => [2, 3, 4]
$it->count
# => 3
See how she justβ¦ works? πβ¨ The array goes in, the iterator comes out, and she's giving main character energy the entire time.
π METHODS π
π new($arrayRef)
Create a brand new iterator object from $arrayRef. That's it. Hand her an arrayref, she hands you back a whole Iterable. Slay. π
π to_array
Return all the items in the Iterator as an ARRAY ref. Everything she's holding, back in your hands, in array form. Iconic behaviour. π
π each(&callback)
For each item in the Iterator, execute the callback function with the item as the first argument. And she's generous β she returns the number of items in the Iterator. So you get your loop and a headcount. Two birds, one module. π¦
π count
Return the count of all the items in the Iterator. Just the number. The whole number. Nothing but the number. Lowkey the most satisfying method here. β
π first
Return the first item from the Iterator. Only the first one. She's not giving you the rest, bestie β that's what the other methods are for. π
π SEE ALSO π
Go read these next, they're the friend group:
Catmandu::IterableCatmandu::Iterator
And that's the whole page, bestie β no notes, ate, periodt. πβ¨
This one's running on perl v5.40.1 and it was stamped 2026-01-24, so likeβ¦ freshly dated, freshly cunty. π Take care of her, she's doing her best. π«Ά
π¦ 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