autobo...t::Util(3pm)
π¦ NAME π¦
autobox::List::Util β it brings the List::Util functions to autobox, bestie π
(also hi, you're reading the autobo...t::Util(3pm) page from the User Contributed Perl Documentation β that's the whole vibe of this file, and we're gonna get into it)
β VERSION β
Version 20090629 β¨ (yes she's an elder, and yes she still slays)
π SYNOPSIS π
Okay so here's the whole entire concept: "autobox::List::Util" brings all of the functions from List::Util to arrays as methods. Like, arrays get methods now. Main character energy fr fr π
use autobox::List::Util;
my @array = qw/ foo bar baz /;
print @array->first(sub { /ar/ }), "\n"; # "bar"
print [5, 6, 3, 4]->max, "\n"; # 6
print @array->maxstr, "\n"; # baz
print [5, 6, 3, 4]->min, "\n"; # 3
print @array->minstr, "\n"; # foo
print [1 .. 10]->shuffle, "\n"; #1 to 10 randomly shuffled
print [1 .. 10]->sum, "\n"; # 55
print [1 .. 10]->reduce( sub { $a + $b } ), "\n"; # 55
Look at those comments, they're the receipts, keep them exactly as-is π
πΈ METHODS πΈ
π first(coderef)
This one behaves nearly the same as the first function from List::Util, but β plot twist β it takes a coderef and not a block, because methods can't use prototypes. That's just the rules, no cap π
π reduce(coderef)
Same deal, bestie: this behaves nearly the same as the reduce function from List::Util, but it takes a coderef instead of a block, for the exact same reason (prototypes, methods, they don't mix, it's giving forbidden love π).
β οΈ Heads up though β it also has a bug. Scroll down to BUGS, I got you.
π shuffle
Iconic behaviour change incoming: if it's called in scalar context, it returns a reference to an array instead of a list. Why? So that shuffle can be chained with other calls. She's flexible like that π¦β¨
π max, maxstr, min, minstr, sum
These methods behave exactly the same as their List::Util counterparts. No drama, no surprises, just the classics doing their thing π
π AUTHOR π
Chas. J. Owens IV, "<chas.owens at gmail.com>" π«Ά
π BUGS π
Okay so the reduce method works with $main::a and $main::b, NOT your current package's $a and $b. So if you're not living in the main package, you literally have to say:
print @array->reduce( sub { $main::a + $main::b } ), "\n";
That's the workaround, periodt.
Good news though: reduce uses $_, so it doesn't suffer from this problem. One of them is fine, one of them is messy, it's giving sibling energy π
π 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
http://rt.cpan.org/NoAuth/Bugs.html?Dist=autobox-List-Util
- π AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/autobox-List-Util
- π CPAN Ratings
http://cpanratings.perl.org/d/autobox-List-Util
- π Search CPAN
http://search.cpan.org/dist/autobox-List-Util/
π§ ACKNOWLEDGEMENTS π§
(no cap, this section is literally empty in the original β nothing to see here, moving on, she said nothing bestie π )
π 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.
and that's the whole page!! π she's perl v5.34.0, dated 2022-06-08, and she ate, no crumbs. byeeee π«Άβ¨π
π¦ where this page comes from
- debian bookworm: libautobox-list-util-perl 20090629-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libautobox-list-util-perl 20090629-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libautobox-list-util-perl 20090629-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libautobox-list-util-perl 20090629-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libautobox-list-util-perl 20090629-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms