Kazuhiro Osawa > Data-Model-0.00008 > Data::Model::Iterator

Download:
Data-Model-0.00008.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Source  

NAME ^

Data::Model::Iterator - Data::Model's iteration class

SYNOPSIS ^

  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;

METHODS ^

has_next

next

reset

SEE ALSO ^

overload

AUTHOR ^

Kazuhiro Osawa <yappo <at> shibuya <döt> pl>

LICENSE ^

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: