If you're trying to count the number of occurrences of each array element, what you want is:
my @array = qw( a b r a c a d a b r a );
my %counts;
++$counts{$_} for @array;
for my $key ( sort { {$counts{$b} <=> $counts{$a} } keys %counts ) {
print("$key: $counts{$key}\n");
}