in reply to Re: how to print top 5 elements from a hash
in thread how to print top 5 elements from a hash
my %hash = ( 'b' => '2', 'a' => '1', 'c' => '3', 'f' => '6', 'e' => '5', 'd' => '4' ); foreach my $key ( (sort keys %hash)[0..4] ) { print "$key ==> $hash{$key}\n" } #prints.. #a ==> 1 #b ==> 2 #c ==> 3 #d ==> 4 #e ==> 5
|
|---|