Utils(3pm)

πŸ“¦
version 0.5 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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!! πŸ’Œ


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