Gopal Karunakar <gk.kalipuray...@gmail.com> 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 %seen){
  print "item $item seen $seen{$item} times.\n"
}

__END__

HTH,
Thomas

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to