Output should be like...%hash1 = ( a, b, c, d, e, f ); %hash2 = ( a, J, e, K ); use Data::Dumper; print Dumper ( \%hash1 ); print Dumper ( \%hash2 ); # WHAT TO DO HERE TO GET UPDATED VALUES ?? print "=========AFTER===========\n"; print Dumper ( \%hash1 ); #print Dumper ( \%hash2 );
I had the following ways of doing it...$VAR1 = { 'e' => 'f', 'c' => 'd', 'a' => 'b' }; $VAR1 = { 'e' => 'K', 'a' => 'J' }; =========AFTER=========== $VAR1 = { 'e' => 'K', 'c' => 'd', 'a' => 'J' };
%hash1 = ( %hash1, %hash2 );
The first way seems promising as i have the requirement of only the first hash keys remain as it is, where as the 2nd way shown here will put the 2nd hash sets unique keys also into the 1st hash.
Question is
I would not want to run over all the hash keys and then do this operation ?! Do you have any single liner, or some statement which can do this operation smarter ?
In reply to merging two hashes and updating the 1st hash keys. by sathiya.sw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |