Beta Shell
v2.0 ยท web2.us.cloudlogin.co
[FM]
[CMD]
[PHP]
[DB]
[INFO]
[SEC]
File Manager
~
/
usr
/
share
/
doc
/
perl-Class-Iterator
Upload
3 items
Name
Size
Perms
Modified
Actions
[ .. / .. ]
README
1.23 KB
-rw-r--r--
2004-01-16 13:04:08
Edit
Del
Editing: README
(1.23 KB)
Path: /usr/share/doc/perl-Class-Iterator/README
Back
NAME Class::Iterator - Iterator class SYNOPSIS use Class::Iterator; my $it = Class::Iterator->new(\&closure_generator); while (my $v = $it->next) { print "value : $v\n" } # use map like my $it2 = imap { ...some code with $_...} $it while (my $v = $it->next) { print "value : $v\n" } # use grep like my $it3 = imap { ...some code with $_...} $it while (my $v = $it->next) { print "value : $v\n" } DESCRIPTION Class::Iterator is a generic iterator object class. It use a closure an wrap into an object interface. new(\&closure_generator) This is the constructor. The argument is a sub which look like sub closure_generator { my $private_data; return sub { # do something with $private_data # and return it return $private_data } } next calling this method make one iteration. $o = imap { ... } $it This a creator. It create a new iterator from an existant iterator in the manner of map. $o = igrep { ... } $it This a creator. It create a new iterator from an existant iterator in the manner of grep. CREDITS Marc Jason Dominius's YAPC::EU 2003 classes. AUTHOR Robert Silve <robert@silve.net>