#define your data: my @hash = ( .1 => 'url1', .2 => 'url2', .3 => 'url3', .7 => 'url7', .9 => 'url9', ); #define the fitness function / match determination my $good_value = sub { $_ > 0.4 }; #find the keys that match the fitness function: my @good_keys = map { $good_value->($_) } keys @hash; #now do something with the keys: ##eg. print the values, in hash order: for my $key (@good_keys) { print $hash{ $key} , "\n"; } ## grab just the urls from the good keys, without including the keys. my @good_values = @hash{ @good_keys }; ##e.g. save a hash with just the subset of new keys my %good_hash; @good_hash{ @good_keys } = @hash{ @good_keys };