Re: How do I count & skip the number of duplicate elements in an array

2006-12-12 Thread Peter Scott
On Mon, 11 Dec 2006 06:02:25 -0800, Rinku Mahesh wrote: > - > my @fields =(); > my @unique_elements=(); > my %seen = (); > > > foreach my $elem (@fields) { > next if $seen{ $elem }++; > push (@unique_elements, $elem); > } > - >

Re: How do I count & skip the number of duplicate elements in an array

2006-12-11 Thread John W. Krahn
Rinku Mahesh wrote: > Hi, Hello, > I've an array storing some numbers , out of which few are duplicate. > I'd like to skip those which are duplicate and save them in a new > array and same time I wish to count the number of skipped/duplicate > elements. > > Eg:- > > Given Array "fields" {12,12

How do I count & skip the number of duplicate elements in an array

2006-12-11 Thread Rinku Mahesh
Hi, I've an array storing some numbers , out of which few are duplicate. I'd like to skip those which are duplicate and save them in a new array and same time I wish to count the number of skipped/duplicate elements. Eg:- Given Array "fields" {12,12,12,12,17,20,25,100,100,1