in reply to Counting repeated values from an array

Sure, you want to run the array through a hash to count the occurrences of each element

my %count; foreach my $element( @name ) { ++$count{$element}; } foreach my $element( keys %count ) { print "$element = $count{$element}\n"; }

If you want to sort the names alphabetically, use foreach my $element( sort keys %count). If you want to sort by highest count first, use foreach my $element( sort { $count{$b} <=> $count{$a} } )

Do yourself a favour and invest in the Perl Cookbook. It's chock full of useful Perl idioms like this. It's money well spent -- and the only Perl title that never moves far from my console.

update: changed the title of this node to reflect that of the parent node.

--
g r i n d e r