See. the exists, map and grep docs for more info.use Data::Dumper; my @array = qw/ foo bar baz quux /; my %hash = qw/ foo one quux two /; my @found = map { $array[$_] . $hash{$array[$_]} } grep { exists $hash{$array[$_]} } 0 .. $#array; print Dumper(\@found); __output__ $VAR1 = [ 'fooone', 'quuxtwo' ];
_________
broquaint
In reply to Re: hashes: testing for the presence of a key
by broquaint
in thread hashes: testing for the presence of a key
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |