my @numericUnion = union{ $_[0] == $_[1] } [1,2,3], [2,3,4], [9]; #returns ( 1, 2, 3, 4, 9 ) my @stringUnion = union{ $_[0] eq $_[1] } [ qw( aaa bbb ccc ) ], [ qw( bbb ccc ddd ) ]; #returns( 'aaa','bbb','ccc','ddd' ) my @unique = union{ $_[0]->isSameNode } [ qw( list of xml nodes ) ], [ qw( othrer list of xml nodes ) ] #unique node list sub union(&@){ my $eq = shift; @_ == 1 ? @{ $_[0] } : union( $eq, [ @{ $_[0] }, grep &{sub{ !grep $eq->( $_, $_[0] ), @_[1..$#_] }}( $_, @{ $_[0] } ), @{ $_[1] } ], @_[2..$#_] ) }