Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The code;dog = 55 cat = 12
my %hash = ( 'dog' => '5', 'sheep' => '10', 'cat' => '3', ); my %hash2 = ( 'dog' => '11', 'budgie' => '1', 'cat' => '4', ); foreach (keys %hash2) { if (exists $hash{$_}) { print "$_ exists"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: comparing keys and values in different hashes
by fruiture (Curate) on Mar 03, 2003 at 14:04 UTC | |
|
Re: comparing keys and values in different hashes
by broquaint (Abbot) on Mar 03, 2003 at 14:06 UTC | |
|
Re: comparing keys and values in different hashes
by robartes (Priest) on Mar 03, 2003 at 14:04 UTC | |
|
Re: comparing keys and values in different hashes
by Russ (Deacon) on Mar 03, 2003 at 18:46 UTC |