for my $i ( 0 .. 4 ) { my $key = $sorted_keys[$i]; print "$hash{$key}\n"; }
or
for my $key ( @sorted_keys[ 0 .. 4 ] ) { print "$hash{$key}\n"; }
or
my @values = @hash{ @sorted_keys[ 0 .. 4 ] };
In reply to Re: how to print top 5 elements from a hash
by ikegami
in thread how to print top 5 elements from a hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |