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?

Combining your loops into one:
my @a = qw/ 1 2 3 4 5 6 7 8 9 5 7 9 5 /; my %seen; my @dups = grep ++$seen{$_}==2, @a; print "@dups\n";
  • 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 FunkyMonk (Bishop) on Jul 27, 2007 at 15:26 UTC
    That's damned sneaky. I like it++