Catmandu::ArrayIterator - Convert an arrayref to an Iterable object
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
Create a new iterator object from $arrayRef.
Return all the items in the Iterator as an ARRAY ref.
For each item in the Iterator execute the callback function with the item as first argument. Returns the number of items in the Iterator.
Return the count of all the items in the Iterator.
Return the first item from the Iterator.
Catmandu::Iterable, Catmandu::Iterator
To install Catmandu, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catmandu
CPAN shell
perl -MCPAN -e shell install Catmandu
For more information on module installation, please visit the detailed CPAN module installation guide.