I know how to avoid duplicates in a one-dimensional array.
However, I have an array of arrays, and two lines of it may hold arrays with different references, but same values. I tried this:
sub unique {
my %seen;
grep !$seen{join('',$_)}++, @_
}
my @aa = ( ["1","2","3"],["1","2","3"],["1","2","4"] );
my @bb = unique(@aa);
print $_ for (@bb);
It should remove one of the two "123" arrays, but it doesn't. Probably because $_ holds a reference and not an array that can be joined? Of couse, I could loop through the $_ referenced array and concat all values, then use that as key to the %seen hash.
But I suspect there is a very elegant solution in Perl that I don't yet know of...