in reply to •Re: finding union, intersection and differences of arrays
in thread finding union, intersection and differences of arrays

I seem to have nothing better to do, but in case you have more than two arrays..
my ($only_a, $only_b, $only_c, $all, $any) = listy(\@a, \@b, \@c); sub listy { my %tmp1; my @keys; for (0..$#_) { my $key = pop @keys; push @keys, $_, (defined $key ? $key : '') . $_; for my $k (@{$_[$_]}) { $tmp1{$k} .= $_; } } my %tmp2; while (my($k, $v) = each %tmp1) { push @{$tmp2{$v}}, $k; } return @tmp2{@keys}, [keys %tmp1]; }
(maybe I should have tested it better the first time. Fixed bug) Jasp