in reply to Re: What is the best way to get just the duplicates from an array?
in thread What is the best way to get just the duplicates from an array?

Thanks! The perlfaq4 example (with the ! for unique removed) is the one that I'll use from now on.

my %seen = (); my @duplicates = grep { $seen{ $_ }++ } @array;
  • Comment on Re^2: What is the best way to get just the duplicates from an array?
  • Download Code

Replies are listed 'Best First'.
Re^3: What is the best way to get just the duplicates from an array?
by ikegami (Patriarch) on Jul 27, 2007 at 16:09 UTC
    That won't work. If there's three of the same thing, it will print the duplicate twice. That's why I used == in my earlier post instead of (an implied) >.