in reply to Selection of Hash key value pairs
In that case, using a heap data structure as implemented by Heap::Simple could be a better solution:
use Heap::Simple; my %data = (...); my $heap = Heap::Simple->new(order => 'gt'); $heap->insert(keys %data); for (1..int(0.1 * keys %data)) { my $key = $heap->extract_top; print "key: $key, value: $data{$key}\n" }
|
|---|