SYNOPSIS use Array::Set qw(set_diff set_symdiff set_union set_intersect); set_diff([1,2,3,4], [2,3,4,5]); # => [1] set_diff([1,2,3,4], [2,3,4,5], [3,4,5,6]); # => [1] set_diff({ignore_case=>1}, ["a","b"], ["B","c"]); # => ["a"] set_symdiff([1,2,3,4], [2,3,4,5]); # => [1,5] set_symdiff([1,2,3,4], [2,3,4,5], [3,4,5,6]); # => [1,6] set_union([1,3,2,4], [2,3,4,5]); # => [1,3,2,4,5] set_union([1,3,2,4], [2,3,4,5], [3,4,5,6]); # => [1,3,2,4,5,6] set_intersect([1,2,3,4], [2,3,4,5]); # => [2,3,4] set_intersect([1,2,3,4], [2,3,4,5], [3,4,5,6]); # => [3,4] DESCRIPTION This module provides routines for performing set operations on arrays. Set is represented as a regular Perl array. All comparison is currently done with eq (string comparison) so currently no support for references/objects/undefs. You have to make sure that the arrays do not contain duplicates/undefs. Characteristics and differences with other similar modules: * simple functional (non-OO) interface * functions accept more than two arguments * option to do case-insensitive comparison * option to ignore blanks * preserves ordering FUNCTIONS All functions are not exported by default, but exportable. set_diff([ \%opts ], \@set1, ...) => array Perform difference (find elements in the first set not in the other sets). Accept optional hashref as the first argument for options. Known options: * ignore_case => bool (default: 0) If set to 1, will perform case-insensitive comparison. * ignore_blanks => bool (default: 0) If set to 1, will ignore blanks (" foo" == "foo" == "f o o"). set_symdiff([ \%opts ], \@set1, ...) => array Perform symmetric difference (find elements in the first set not in the other set, as well as elements in the other set not in the first). Accept optional hashref as the first argument for options. See set_diff for known options. set_union([ \%opts ], \@set1, ...) => array Perform union (find elements in the first or in the other, duplicates removed). Accept optional hashref as the first argument for options. See set_diff for known options. set_intersect([ \%opts ], \@set1, ...) => array Perform intersection (find elements common in all the sets). Accept optional hashref as the first argument for options. See set_diff for known options. SEE ALSO See some benchmarks in Bencher::Scenarios::ArraySet. App::setop to perform set operations on lines of files on the command-line. Array::Utils, Set::Scalar, List::MoreUtils (uniq for union, singleton for symmetric diff), Set::Array, Array::AsObject, Set::Object, Set::Tiny.