note
inman
An alternative method uses the each and keys functions to iterate over a hash and locate the keys. This has the advantage of coping with the more general case wher multiple instances of a value in addition to not requiring the storage of another hash.
<c>
my @keys = qw ( a b c d e f g h i j);
my @vals = qw ( 1 1 1 4 5 6 7 8 9 0);
my %hash;
@hash{@keys} = @vals;
my @ones = grep {(each %hash)[1] == 1} keys %hash;
print "@ones\n";
</c>
<p>
Inverting the hash as shown previously is a better method if you are OK with the storage overhead and you will be doing multiple retrievals.
541317
541317