my $count = 0; for ( sort { $a cmp $b } keys %hash ) { print "$_ => $hash{$_}\n" if $count++ < 10; }