I didn't try to run your code since it's not a complete working program. Here's one way to get what I think you want:
#!/usr/bin/perl use strict; use warnings; my %hash; %hash = map { $_ => ++$hash{ $_ } } (split ' ', <DATA>); for (sort { $hash{$b} <=> $hash{$a} } keys %hash) { print "$_ => $hash{ $_ }\n"; last; } __DATA__ 2 3 3 3 5 7 8 12 32 44 55 12 3 23 43 33 1 4 25 43 42 1 4 5 3 3 3
In reply to Re: Help fixing this piece of code
by 1nickt
in thread Help fixing this piece of code
by perlynewby
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |