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" }
In reply to Re: Selection of Hash key value pairs
by salva
in thread Selection of Hash key value pairs
by Gavin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |