use strict; use warnings; my %hash = ( foo => 'bar', 42 => 23, hello => 'world', ); my @interesting_keys = qw(foo hello); my @values = map { $hash{$_} } @interesting_keys; my @interesting_values = qw(bar 23); my %reversed_hash = reverse %hash; my @keys = map { $reversed_hash{$_} } @interesting_values;
Update: Made the code conform to strict, after tirwhan's note.
In reply to Re: Returning value or key from a hash
by Corion
in thread Returning value or key from a hash
by Gavin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |