Re: Find duplicates in an array

2010-06-02 Thread C.DeRykus
On Jun 2, 12:37 am, gk.kalipuray...@gmail.com (Gopal Karunakar) wrote: > Hi All, > > I needed to find all the duplicate values in an array and their count of > occurences. Any help would be appreciated . > See: perldoc -q dup perldoc perlvar Although even non-dup array members get printed

RE: Find duplicates in an array

2010-06-02 Thread Taylor, Andrew (ASPIRE)
>I needed to find all the duplicate values in an array and their count of >occurences. Any help would be appreciated . You could use a hash: use strict; use warnings; my @animals = ("cat","dog","wombat","cat","monkey","cat","monkey"); my %howmany; foreach my $critter (@animals) { $howmany{$cr

AW: Find duplicates in an array

2010-06-02 Thread Thomas Bätzler
Gopal Karunakar asked: > I needed to find all the duplicate values in an array and their count > of occurences. Any help would be appreciated . #!/usr/bin/perl -w use strict; my @array=qw(foo baz bar foo baz foo); my %seen; foreach my $item (@array){ $seen{$item}++ } foreach my $item (keys

Find duplicates in an array

2010-06-02 Thread Gopal Karunakar
Hi All, I needed to find all the duplicate values in an array and their count of occurences. Any help would be appreciated . Thanks in advance.