use strict; my %hash = ( a_one => 1, b_two => 2, c_three => 3, d_four => 4, e_five => 5, f_six => 6, g_seven => 7, h_eight => 8, i_nine => 9, j_ten => 10 ); my $pairs = (keys %hash); my $counter = 0; my $amount_to_print = int(0.20 * $pairs); foreach my $key (reverse sort keys %hash) { if ($counter < $amount_to_print) { print $key, ' ', $hash{$key}, "\n"; } else { last; } $counter++; } #### j_ten 10 i_nine 9