in reply to Mutually Exclusive Elements

Not sure exactly what you're trying to do here, but I've assumed that you want an output of 3 values for each array, the first two being the most unique two values and equal uniqueness being decided by array position, and the third being the first value common to all arrays. I know this doesn't yield the same output as what you have, but I wasn't sure what you wanted:
use strict; use warnings; my (@sets, $n, %c, @u, @a); while (<DATA>) { chomp; push @sets, [split /,/]; } for (@sets) { $c{$_}++ for (@$_); } $n = $#sets + 1; for (@sets) { print '[' . join(',', @$_) . '] = ['; @u = (); @a = (); for (@$_) { if ($c{$_} != $n) { push(@u, [$_, $c{$_}]); } else { push (@a, $_); } } for ((sort {@$a[1] cmp @$b[1]} @u)[0..1]) { print @$_[0] . ','; } print $a[0] . "]\n"; } __DATA__ 1,2,3,4,5,6 3,4,5,7,8 3,6,8,9
The key is the counts:
for (@sets) { $c{$_}++ for (@$_); }
This gives you the total number of times each value is used over the entire nested array. If the number is equal to the number of arrays, then the value is common to all arrays; if the number is 1, then the value is unique to whichever array contains it. Numbers in between can be used to fill in if there aren't enough 1's, as shown above.

I've assumed that there are always at least two values in each array not common to all arrays. I've also assumed that the arrays can contain non-numerical values, which is why I'm using cmp for the sort instead of <=>.