Object::Iterate

Iterators for objects that know the next element
Download

Object::Iterate Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • brian d foy
  • Publisher web site:
  • http://search.cpan.org/~bdfoy/

Object::Iterate Tags


Object::Iterate Description

Iterators for objects that know the next element Object::Iterate is a Perl module that provides control structures to iterate through the elements of an object that cannot be represented as list of items all at once. Objects can represent a virtual collection that is beyond the reaches of foreach, map, and grep because they cannot turn themselves into a list.If the object can return a next element, it can use this module. Iterate assumes that the object responds to __next__ with the next element, and to __more__ with TRUE or FALSE if more elements remain to be processed. The __init__ method is called before the first iteration (if it exists), and is silently skipped otherwise. The control structure continues until the __more__ method returns FALSE (which does not mean that it visited all of the elements but that the object has decided to stop iterating). At the end of all iterations (when __more__ returns false), Object::Iterate calls __final__ if it exists, and skips it otherwise.Each control structure sets $_ to the current element, just like foreach, map, and grep.SYNOPSIS use Object::Iterate qw(iterate igrep imap); iterate {...} $object; my @filtered = igrep {...} $object; my @transformed = imap {...} $object; Requirements: · Perl


Object::Iterate Related Software