in reply to Re: Eliminate Array of array duplication
in thread Eliminate Array of array duplication

I would agree with ikegami's post above, the only thing I'd add it that you should probably sort the array before using it as a key, if [1, 2, 3] , [3, 2, 1] and [2, 1, 3] are considered identical.
my %seen; @AoD = grep !$seen{ join(',', (sort {$a<=>$b} @$_ )) }++, @AoD;
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

Replies are listed 'Best First'.
Re^3: Eliminate Array of array duplication
by ikegami (Patriarch) on May 19, 2011 at 10:02 UTC

    Indeed. If one desires for [1,2,3] and [3,2,1] to be considered identical, they must have identical signatures, and that can be achieved by sorting the numbers.

    I doubt that's going to be a common desire, but if it happens, it's probably cleaner to normalise the data before finding the dups.

    # Normalise the data. @$_ = sort { $a <=> $b } @$_ for @AoD; # Filter out duplicates. my %seen; @AoD = grep !$seen{ join(',', @$_) }++, @AoD;