for my $i (1..$numberOfBestFrags) { our $index = 0; our $maxGoodness = 0; while(($key, $value) = each %fragmentResultSetH) { if($value{goodness} > $maxGoodness) { $maxGoodness = $value{goodness}; $index = $key; }   ; } push @tenBestFrags, $fragmentResultSetH{"$index"}; delete $fragmentResultSetH{"$index"}; }