Array::Utils3pm
Small utils for array manipulation
Usage
use Array::Utils qw(:all);my @a = qw( a b c d );my @b = qw( c d e f );# symmetric differencemy @diff = array_diff(@a, @b);# intersectionmy @isect = intersect(@a, @b);# unique unionmy @unique = unique(@a, @b);# check if arrays contain same membersif ( !array_diff(@a, @b) ) {# do something}# get items from array @a that are not in array @bmy @minus = array_minus( @a, @b );
Overview
A small pure-perl module containing list manipulation routines. The module emerged because I was tired to include same utility routines in numerous projects.
Functions
- "unique"
-
Returns an array of unique items in the arguments list.
- "intersect"
-
Returns an intersection of two arrays passed as arguments, keeping 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
- "array_diff"
-
Return symmetric difference of two arrays passed as arguments.
- "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). If an empty array is returned, A is subset of B.
Function was proposed by Laszlo Forro <[email protected]>.
Warranty
This is free software. IT COMES WITHOUT WARRANTY OF ANY KIND.
Releases
5 releases since Debian 9 (Stretch); the text changed 2 times.