Re: Duplicates elements in an array

2006-02-06 Thread Jeff Pang
Do you want to keep the duplicate elements simply and don't mind the order of them? If I have understood for you correctly,I should write the code as below: use strict; use warnings; my @array = qw/aaa bbb ccc aaa ddd ddd aaa ccc bbb bbb/; my %hash; $hash{$_}++ for @array; my @duplicate = grep {

Re: Duplicates elements in an array

2006-02-06 Thread John Doe
anand kumar am Montag, 6. Februar 2006 08.34: > Hi all > > I have an array with hundreads of elements in it. Can anyone > suggest the easiest way to keep only the duplicate elements in the array. Hi Anand Depends a bit if you want to keep all duplicates of a duplicate element or jus