in reply to merging two hashes and updating the 1st hash keys.
#!/usr/bin/perl use strict; my %hash_1 = ( 'a' => 'b', 'c' => 'd', 'e' => 'f' ); my %hash_2 = ( 'a' => 'J', 'e' => 'K' ); my %new_hash; $new_hash{$_} = $hash_2{$_} ? $hash_2{$_} : $hash_1{$_} for keys %hash_1; print map { $_ => " => " . $new_hash{$_} . "\n" } keys %new_hash;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: merging two hashes and updating the 1st hash keys.
by sathiya.sw (Monk) on Aug 28, 2009 at 07:10 UTC |