Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#Result: ideally the change will happen in hash1, butmy %hash1 = ( 700200 => '523235', 700204 => '523221', ); my %hash2 = ( 523235 => 'Title1', 523221 => 'Title2', );
My code does not work at all, only return an empty hashmy $value1; foreach my $key1 (keys(%hash1)) { $value1 = $hash1{key1}; foreach my $key2 (keys (%hash2)) { if ($value1 eq $key2){ $hash3{$key1}= $hash2{$key2}; } } } print Dumper \%hash3; #this should be the expected result $VAR1 = { 700200 => 'Title1', 700204 => 'Title2', };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Replace the value of a hash
by dragonchild (Archbishop) on Apr 01, 2004 at 22:26 UTC | |
|
Re: Replace the value of a hash
by Roy Johnson (Monsignor) on Apr 01, 2004 at 23:21 UTC | |
|
Re: Replace the value of a hash
by duff (Parson) on Apr 01, 2004 at 22:27 UTC | |
|
Re: Replace the value of a hash
by Anonymous Monk on Apr 01, 2004 at 22:30 UTC | |
by Anonymous Monk on Apr 02, 2004 at 00:26 UTC | |
by Anonymous Monk on Apr 01, 2004 at 22:35 UTC | |
|
Re: Replace the value of a hash
by ambrus (Abbot) on Apr 02, 2004 at 20:19 UTC | |
by qq (Hermit) on Apr 02, 2004 at 21:22 UTC | |
by ambrus (Abbot) on Apr 03, 2004 at 20:31 UTC | |
|
Re: Replace the value of a hash
by ambrus (Abbot) on May 06, 2008 at 15:33 UTC |