1autobox::List::Util(3)User Contributed Perl Documentationautobox::List::Util(3)
2
3
4

NAME

6       autobox::List::Util - bring the List::Util functions to autobox
7

VERSION

9       Version 20090629
10

SYNOPSIS

12       "autobox::List::Util" brings all of the functions from List::Util to
13       arrays as methods.
14
15           use autobox::List::Util;
16
17           my @array = qw/ foo bar baz /;
18
19           print @array->first(sub { /ar/ }), "\n"; # "bar"
20
21           print [5, 6, 3, 4]->max, "\n"; # 6
22
23           print @array->maxstr, "\n"; # baz
24
25           print [5, 6, 3, 4]->min, "\n"; # 3
26
27           print @array->minstr, "\n"; # foo
28
29           print [1 .. 10]->shuffle, "\n"; #1 to 10 randomly shuffled
30
31           print [1 .. 10]->sum, "\n"; # 55
32
33           print [1 .. 10]->reduce( sub { $a + $b } ), "\n"; # 55
34

METHODS

36   first(coderef)
37       This method behaves nearly the same as the first function from
38       List::Util, but it takes a coderef not a block because methods can't
39       use prototypes.
40
41   reduce(coderef)
42       This method behaves nearly the same as the reduce function from
43       List::Util, but it takes a coderef not a block for the same reason.  It
44       also has a bug (see BUGS)
45
46   shuffle
47       If called in scalar context it returns a reference to an array instead
48       of a list.  This allows shuffle to be chained with other calls.
49
50   max, maxstr, min, minstr, sum
51       These methods behave exactly the same as their List::Util counterparts.
52

AUTHOR

54       Chas. J. Owens IV, "<chas.owens at gmail.com>"
55

BUGS

57       The reduce method works with $main::a and $main::b, not your current
58       package's $a and $b, so you need to say
59
60           print @array->reduce( sub { $main::a + $main::b } ), "\n";
61
62       if you are not in the main package.  Reduce uses $_, so it doesn't
63       suffer from this problem.
64

SUPPORT

66       You can find documentation for this module with the perldoc command.
67
68           perldoc autobox::List::Util
69
70       You can also look for information at:
71
72       ·   RT: CPAN's request tracker
73
74           http://rt.cpan.org/NoAuth/Bugs.html?Dist=autobox-List-Util
75           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=autobox-List-Util>
76
77       ·   AnnoCPAN: Annotated CPAN documentation
78
79           http://annocpan.org/dist/autobox-List-Util
80           <http://annocpan.org/dist/autobox-List-Util>
81
82       ·   CPAN Ratings
83
84           http://cpanratings.perl.org/d/autobox-List-Util
85           <http://cpanratings.perl.org/d/autobox-List-Util>
86
87       ·   Search CPAN
88
89           http://search.cpan.org/dist/autobox-List-Util/
90           <http://search.cpan.org/dist/autobox-List-Util/>
91

ACKNOWLEDGEMENTS

94       Copyright 2009 Chas. J. Owens IV, all rights reserved.
95
96       This program is free software; you can redistribute it and/or modify it
97       under the same terms as Perl itself.
98
99
100
101perl v5.12.3                      2011-08-16            autobox::List::Util(3)
Impressum