Utils(3pm)
π Utils(3pm) β Array::Utils, bestie edition π
okay so. this is the manual page for Array::Utils, a lil Perl module (it lives in section 3pm, the User Contributed Perl Documentation zone, iykyk). it's small, it's pure-perl, and it's about to make your arrays behave. let's go π¦
β¨ NAME β¨
Array::Utils β small utils for array manipulation πΈ
like, small. but mighty. no cap.
β¨ SYNOPSIS β¨
use Array::Utils qw(:all);
my @a = qw( a b c d );
my @b = qw( c d e f );
# symmetric difference
my @diff = array_diff(@a, @b);
# intersection
my @isect = intersect(@a, @b);
# unique union
my @unique = unique(@a, @b);
# check if arrays contain same members
if ( !array_diff(@a, @b) ) {
# do something
}
# get items from array @a that are not in array @b
my @minus = array_minus( @a, @b );
see how it just works? import :all and the whole squad shows up. slay. π
β¨ DESCRIPTION β¨
it's a small pure-perl module stuffed with list manipulation routines. that's the whole vibe. π
and the reason it exists?? iconic origin story tbh: the author got tired of copy-pasting the same utility routines into, like, numerous projects. so he made one module instead. main character energy fr fr. β¨
β¨ FUNCTIONS β¨
unique
Returns an array of unique items in the arguments list. dupes? we don't know her. π
intersect
Returns an intersection of two arrays passed as arguments β and it keeps the order of the second parameter. π
a nice side effect of this function can be exploited in situations as:
@atreides = qw( Leto Paul Alia 'Leto II' );
@mylist = qw( Alia Leto );
@mylist = intersect( @mylist, @atreides ); # and @mylist is ordered as Leto,Alia
so @mylist comes out ordered as Leto,Alia. the order follows the second array, not the first. remember that, bestie, it's the whole trick π«Ά
array_diff
Returns the symmetric difference of two arrays passed as arguments. π (in a cute way. it's giving "what's in one but not both".)
array_minus
Returns the difference of the passed arrays A and B β only those array elements that exist in A and do not exist in B. π
pro tip from the docs themselves: if an empty array is returned, A is a subset of B.
this function was proposed by Laszlo Forro <salmonix@gmail.com>. shoutout, king. π
β¨ BUGS β¨
None known yet. π
(none known yet β the "yet" is doing a lot of heavy lifting there ngl)
β¨ AUTHOR β¨
Sergei A. Fedorov <zmij@cpan.org> π
and he says, quote: "I will be happy to have your feedback about the module." so if you have thoughts, send them!! he literally asked!! π
β¨ COPYRIGHT β¨
This module is Copyright (c) 2007 Sergei A. Fedorov. All rights reserved.
You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. β
β¨ WARRANTY β¨
This is free software. IT COMES WITHOUT WARRANTY OF ANY KIND. π¨
no warranty bestie. none. zero. zip. it's free, so it's on you. π /lh
that's the whole page!! thanks for reading, you ate πβ¨
kisses, and remember: perl v5.36.0, dated 2022-10-15, straight from the Utils(3pm) manual. byeeee ππ¦πΈ
π¦ where this page comes from
- ubuntu noble: libarray-utils-perl 0.5-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libarray-utils-perl 0.5-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libarray-utils-perl 0.5-3 Β· 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