NAME

I - Iterator

SYNOPSIS

use I;

my $it =  I->new( [qw/a b c/] );

my $first =  $it->first;  # a
my $next  =  $it->next;   # b
my $pos   =  $it->pos;    # 1
my $item  =  $it->item;   # b

DESCRIPTION

I is a tiny iterator over an array reference. It tracks the current position and returns items from the underlying array. Could be used when you are trying to mock iteration over ResultSet. See DBIx::Class.

METHODS

new

my $it =  I->new( $arrayref );

Create a new iterator for the given array reference.

pos

my $pos =  $it->pos;

Return the current position, or undef if iteration has not started.

item

my $value =  $it->item;
my $value =  $it->item( $pos );

Return the item at the given $index or at the current position.

first

my $value =  $it->first;

Set position to 0 and return the first item.

next

my $value =  $it->next;

Increment the position and return the next item.

SEE ALSO

A, C, I, L, M, S, T, U.