NAME
autobox::List::Util - bring the List::Util functions to autobox
VERSION
Version 20090629
SYNOPSIS
autobox::List::Util
brings all of the functions from List::Util to arrays as methods.
use
autobox::List::Util;
my
@array
=
qw/ foo bar baz /
;
@array
->first(
sub
{ /ar/ }),
"\n"
;
# "bar"
[5, 6, 3, 4]->max,
"\n"
;
# 6
@array
->maxstr,
"\n"
;
# baz
[5, 6, 3, 4]->min,
"\n"
;
# 3
@array
->minstr,
"\n"
;
# foo
[1 .. 10]->shuffle,
"\n"
;
#1 to 10 randomly shuffled
[1 .. 10]->sum,
"\n"
;
# 55
[1 .. 10]->reduce(
sub
{
$a
+
$b
} ),
"\n"
;
# 55
METHODS
first(coderef)
This method behaves nearly the same as the first function from List::Util, but it takes a coderef not a block because methods can't use prototypes.
reduce(coderef)
This method behaves nearly the same as the reduce function from List::Util, but it takes a coderef not a block for the same reason. It also has a bug (see BUGS)
shuffle
If called in scalar context it returns a reference to an array instead of a list. This allows shuffle to be chained with other calls.
max, maxstr, min, minstr, sum
These methods behave exactly the same as their List::Util counterparts.
AUTHOR
Chas. J. Owens IV, <chas.owens at gmail.com>
BUGS
The reduce method works with $main::a and $main::b, not your current package's $a and $b, so you need to say
@array
->reduce(
sub
{
$main::a
+
$main::b
} ),
"\n"
;
if you are not in the main package. Reduce uses $_, so it doesn't suffer from this problem.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc autobox::List::Util
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
Copyright 2009 Chas. J. Owens IV, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.