List::MoreUtils::Impl::Alias - Provide List::MoreUtils implementation by Adam Kennedy
use List::MoreUtils qw(:alias);
Returns a true value if any item in LIST meets the criterion given through BLOCK. Sets $_ for each item in LIST in turn:
$_
print "At least one value undefined" if any { ! defined($_) } @list;
Returns false otherwise, or if LIST is empty.
The behaviour without LIST needs to be discussed!
Returns a true value if all items in LIST meet the criterion given through BLOCK, or if LIST is empty. Sets $_ for each item in LIST in turn:
print "All items defined" if all { defined($_) } @list;
Returns false otherwise.
Logically the negation of any. Returns a true value if no item in LIST meets the criterion given through BLOCK, or if LIST is empty. Sets $_ for each item in LIST in turn:
any
print "No value defined" if none { defined($_) } @list;
Logically the negation of all. Returns a true value if not all items in LIST meet the criterion given through BLOCK. Sets $_ for each item in LIST in turn:
all
print "Not all values defined" if notall { defined($_) } @list;
Returns the list of values sorted according to the string values returned by the KEYFUNC block or function. A typical use of this may be to sort objects according to the string value of some accessor, such as
sort_by { $_->name } @people
The key function is called in scalar context, being passed each value in turn as both $_ and the only argument in the parameters, @_. The values are then sorted according to string comparisons on the values returned. This is equivalent to
sort { $a->name cmp $b->name } @people
except that it guarantees the name accessor will be executed only once per value. One interesting use-case is to sort strings which may have numbers embedded in them "naturally", rather than lexically.
sort_by { s/(\d+)/sprintf "%09d", $1/eg; $_ } @strings
This sorts strings by generating sort keys which zero-pad the embedded numbers to some level (9 digits in this case), helping to ensure the lexical sort puts them in the correct order.
Similar to sort_by but compares its key values numerically.
List::Util
Jens Rehsack <rehsack AT cpan.org>
Adam Kennedy <adamk@cpan.org>
Tassilo von Parseval <tassilo.von.parseval@rwth-aachen.de>
Some parts copyright 2011 Aaron Crane.
Copyright 2004 - 2010 by Tassilo von Parseval Copyright 2013 by Jens Rehsack
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.
To install List::MoreUtils, copy and paste the appropriate command in to your terminal.
cpanm
cpanm List::MoreUtils
CPAN shell
perl -MCPAN -e shell install List::MoreUtils
For more information on module installation, please visit the detailed CPAN module installation guide.