in reply to Re: Array Question
in thread Array Question

Using Schwartzian Transform here is overkill, because hash lookups are very efficient. Simplification:

my @letters = qw( red red red blue white yellow blue navy navy green white cars ); my %count; $count{$_}++ foreach @letters; print("$_ => $count{$_}\n") foreach sort { $count{$b} <=> $count{$a} } keys %count;

Output:

red => 3 blue => 2 white => 2 navy => 2 cars => 1 green => 1 yellow => 1

Kudos for being the first to sort the results, though.