Data::Model::Iterator - Data::Model's iteration class
use Data::Model::Iterator;
my @stack = qw( 1 2 );
my $itr = Data::Model::Iterator->new(
sub { ok(1, 'do shift'); shift @stack },
end => sub { ok(1, 'do end') },
reset => sub { ok(1, 'do reset') },
);
#
Dump($itr->next) if $itr->has_next;
# iteration
while (my $row = $itr->next) {
say $row;
# some code
}
while (<$itr>) {
say $_;
# some code
}
while (my $row = <$itr>) {
say $row;
# some code
}
for empty iteration
my $itr = Data::Model::Iterator::Empty->new;
return unless $itr; # bool overload
return unless $itr->has_next;
Kazuhiro Osawa <yappo <at> shibuya <doet> pl>
This library is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
Hey! The above document had some coding errors, which are explained
below:
- Around line 121:
- Non-ASCII character seen before =encoding in '<doet>'. Assuming
UTF-8