for my $i ( 0 .. 4 ) { my $key = $sorted_keys[$i]; print "$hash{$key}\n"; }