my @k = sort keys %the_hash; my $pct = 10; # what percent to print #- WRONG -# for ( 0..int(@k/$pct)-1 ) { for ( 0.. int( @k * ($pct/100) ) )-1 ) { printf "%s => %s\n", $k[$_], $the_hash{$k[$_]} }