Iterator::BreakOnIterator::BreakOn is a Perl module to create iterators with control flow breaks. | |
Download |
Iterator::BreakOn Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Vctor Moral
- Publisher web site:
- http://search.cpan.org/~vmoral/Iterator-BreakOn-0.3/lib/Iterator/BreakOn.pm
Iterator::BreakOn Tags
Iterator::BreakOn Description
Iterator::BreakOn is a Perl module to create iterators with control flow breaks. Iterator::BreakOn is a Perl module to create iterators with control flow breaks.SYNOPSIS use Iterator::BreakOn; # # get a generic data source with a next method implemented whom # returns a generic object # # in this example the order of the items in the data stream is assumed # to be: # location, zipcode, name # my $datasource = $myschema->resultset('mytable')->search(); my $iter = Iterator::BreakOn->new( datasource => $datasource, break_before => , break_after => , on_last_item => sub { print "Finnished !"; }, ); # # There are three uses modes: # # Fully automatic mode: useless if not defined code for breaks $iter->run(); # Semi-automatic mode: get only the item (run automatically the other # events) while (my $data_item = $iter->next()) { # do something with data ... 1; } # Manual mode: get every event as an object while (my $event = $iter->next_event()) { if ($event->name() eq 'before_location') { # do something before a new location comes } elsif ($event->name() eq 'after_zipcode')) { # do something after the last zipcode reached } elsif ($event->name() eq 'next_item' ) { # get the item (including the first and last items) my $data = $iter->next(); # and do something whit him } elsif ($event->name() eq 'last_item') { # and do something when the end of data reached } } # end while Requirements: · Perl
Iterator::BreakOn Related Software