Catman...terator(3pm)

πŸ“¦
version 1.2025 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– 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::Iterable
  • Catmandu::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