Closure::Loop

Closure::Loop is a Perl module with redo, last, next for closure based loops.
Download

Closure::Loop Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Andy Armstrong
  • Publisher web site:
  • http://search.cpan.org/~andya/

Closure::Loop Tags


Closure::Loop Description

Closure::Loop is a Perl module with redo, last, next for closure based loops. Closure::Loop is a Perl module with redo, last, next for closure based loops.SYNOPSIS package MyIterator; use Closure::Loop; # mixin sub new { my $class = shift; return bless { }, $class; } sub forAll { my $self = shift; my $cb = pop || die "No callback"; for my $i (@_) { eval { $self->yield($cb, $i); }; last if $self->is_last; die $@ if $@; } } package main; my $iter = MyIterator->new(); my @in = ( 1, 2, 3 ); my @out = ( ); $iter->forAll(@in, sub { my $i = shift; $iter->next if $i == 2; # skip value push @out, $i; }); # @out is ( 1, 3 )An idea that Perl programmers can usefully borrow from Ruby is the concept of synthesizing new looping constructs by passing a block of code to a function that repeatedly calls it with successive values in a sequence.In Ruby this looks like this: def count_to_ten i = 1 while i Requirements: · Perl


Closure::Loop Related Software