Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 976 Categories, Downloaded 29.546.576 Times

Closure::Loop 0.0.2

  Date Added: June 11, 2010  |  Visits: 652

Closure::Loop

Report Broken Link
Printer Friendly Version


Product Homepage
Download (78 downloads)



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 <= 10 yield i i = i + 1 end end count_to_ten do |i| puts i end In Perl the same thing looks like this: sub count_to_ten { my $block = shift; my $i = 1; while ($i <= 10) { $block->($i); $i++; } } count_to_ten(sub { my $i = shift; print "$in"; }); That example is deliberately trivial. In practice this technique can be used to implement a loop like construct that, for example, walks the nodes in a binary tree - something that isnt easy with a normal loop. The body of the loop is actually a closure so it has complete access to the lexical scope in which it is defined. In short it works just like the body of a loop for our purposes - with one exception. For normal Perl loops its possible to use the last, next and redo statements to modify iteration of the loop. That wont work as expected here. If we use them in our pseudo loop well get a warning (because were actually trying to jump out of a subroutine using them) and theyll end up affecting the first enclosing loop or block they find - which may impact unpredictably on the iterator function, particularly if it doesnt actually contain a loop. This module makes it easy to implement modules that expose iterator methods and which provide an interface for controlling the iteration of the loop which resembles an object oriented version of Perls normal loop control statements..

Requirements: No special requirements
Platforms: Linux
Keyword: Closure Closureloop Last Libraries Module Perl Perl Module Programming Redo
Users rating: 0/10

License: Freeware Size: 6.14 KB
USER REVIEWS
More Reviews or Write Review


CLOSURE::LOOP RELATED
Libraries  -  OpenGeoDB Perl module 0.4
OpenGeDB Perl module is a module to access the OpenGeoDB database and calculate all ZIP codes in a certain radius..
3.07 KB  
Libraries  -  XML::Grove 0.46 Alpha
XML::Grove is a Perl module with Perl-style XML objects. SYNOPSIS use XML::Grove; # Basic parsing and grove building use XML::Grove::Builder; use XML::Parser::PerlSAX; $grove_builder = XML::Grove::Builder->new; $parser =...
27.65 KB  
Libraries  -  B::Lint 1.09
B::Lint module contains Perl lint. SYNOPSIS perl -MO=Lint[,OPTIONS] foo.pl The B::Lint module is equivalent to an extended version of the -w option of perl. It is named after the program lint which carries out a similar process for C...
17.41 KB  
Modules  -  Flickr API 5.x-1.x-dev 1.0
You don't need this module unless another module requires it or you want to develop a new Flickr-based module.To use this module a Flickr API key is required.InstallationUnpack in your modules folder (usually /sites/all/modules/) and enable under...
 
Network & Internet  -  MyCMS perl module 1.0
MyCMS perl module provides the MN::CMS Perl module used by the MyCMS. MyCMS perl module contains Perl object classes to manage the data of MyCMS (such as articles, links, and images). MN::CMS is a perl module that allows you to manage an...
16.38 KB  
Libraries  -  Module::Reload::Selective 1.02
Module::Reload::Selective can reload Perl modules during development. SYNOPSIS Instead of: use Foobar::MyModule; Do this: use Module::Reload::Selective; &Module::Reload::Selective->reload(qw(Foobar::MyModule)); Or, if you need the...
10.24 KB  
Libraries  -  Wx::Perl::Packager 0.07
Wx::Perl::Packager provides a module to assist packaging Wx based applications with PAR, ActiveState PerlApp / PDK and Perl A module to assist packaging Wx based applications with PAR, ActiveState PerlApp / PDK and Perl2Exe. All that is needed...
12.29 KB  
Libraries  -  FFI::Library 1.02
FFI::Library is a module with Perl Access to Dynamically Loaded Libraries. SYNOPSIS use FFI::Library; $lib = FFI::Library->new("mylib"); $fn = $lib->function("fn", "signature"); $ret = $fn->(...); This module provides access from Perl to...
16.38 KB  
Libraries  -  perlrpcgen 0.71
perlrpcgen is a Perl module that can generate Perl interfaces from ONC RPC interface definitions. SYNOPSIS perlrpcgen [--makefile] [--all] [--client] [--server] [--data] [--constants] [--module module] [--typemap typemap] [--fork] [--perl...
37.89 KB  
Libraries  -  Lingua::Conjunction 2.00
Lingua::Conjunction is Perl module convert Perl lists into linguistic conjunctions. SYNOPSIS use Lingua::Conjunction; # emits "Jack" $name_list = conjunction(Jack); # emits "Jack and Jill" $name_list = conjunction(Jack, Jill); # emits...
4.1 KB  
NEW DOWNLOADS IN PROGRAMMING, LIBRARIES
Programming  -  FLEX-db Digital Asset Manager 3.0.9
FLEX-db - an enterprise Digital Asset Manager (DAM). It ingests and links metadata with files, creates thumbnails, and processes files using business rules. FLEX-db has a JSP client, Java app server for file input and output and an EJB metadata...
21.57 MB  
Programming  -  Libicom 0.9.0
The libicom library is a character based dynamicly linked library for Linux. It is used to remotely control the Icom IC-R8500 wide band receiver via an RS232 link. All call and return parameters to the control functions are character string based....
20.48 KB  
Programming  -  dotdesktop 0.3
Dotdesktop library provides ability to parse desktop entry file and access the information in a convenient way. Desktop entry file format is defined by freedesktop.org, it is used to describe information about an application such as the name and...
327.68 KB  
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  libyasl 0.2
Libyasl is a C++ class library to easily realize TCP/UDP/Multicast clientsand servers in IPv4 and IPv6 environments under GNU/Linux systems.
143.36 KB  
Libraries  -  EuGTK 4.8.9
Makes it easy to develop good- looking, fast, cross-platform programs that run on Linux, OS X, and Windows. Euphoria is a very fast interpreted/compiled language with straight-forward syntax. EuGTK allows programming in a clean, object-oriented...
10.68 MB  
Libraries  -  Linux User Group Library Manager 1.0
The LUG Library Manager is a project to help Linux User Groups start their own library. A LUG library is helpful to the community at large because it increases access to information, and gives everyone the opportunity to become more knowledgeable.
5.35 KB  
Libraries  -  Module::MakefilePL::Parse 0.12
Module::MakefilePL::Parse is a Perl module to parse required modules from Makefile.PL. SYNOPSIS use Module::MakefilePL::Parse; open $fh, Makefile.PL; $parser = Module::MakefilePL::Parse->new( join("", ) ); $info = $parser->required;...
8.19 KB  
Libraries  -  sqlpp 0.06
sqlpp Perl package is a SQL preprocessor. sqlpp is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also...
10.24 KB  
Libraries  -  App::SimpleScan::Substitution::Line 2.02
App::SimpleScan::Substitution::Line is a line with optional fixed variable values. SYNOPSIS my $line = App::SimpleScan::Substitution::Line->new(" this "); # Use only this value when substituting " ". $line->fix(substituite =>...
54.27 KB