Perl6-Take
Perl 6 provides the "gather" and "take" keywords to construct a list in a free manner.
Instead of:
sub sorted_pairs {
my %somehash = @_;
my @pairs;
for my $key (sort keys %somehash);
push @out, [ $key => $somehash{$key} ];
}
return @pairs;
}
You can say (in Perl 5 syntax):
sub sorted_pairs {
my %somehash = @_;
gather { for my $key (sort keys %somehash);
push @out, [ $key => $somehash{$key} ];
}}
}
(The difference is more marked in Perl 6 syntax all around.)
INSTALLATION
To install this module, run the following commands:
perl Makefile.PL
make
make test
make install
SUPPORT AND DOCUMENTATION
After installing, you can find documentation for this module with the perldoc command.
perldoc Perl6::Take
You can also look for information at:
Search CPAN
http://search.cpan.org/dist/Perl6-Take
CPAN Request Tracker:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Perl6-Take
AnnoCPAN, annotated CPAN documentation:
http://annocpan.org/dist/Perl6-Take
CPAN Ratings:
http://cpanratings.perl.org/d/Perl6-Take
COPYRIGHT (The "MIT" License)
Copyright (C) 2006-2007 Gaal Yahas
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.