Thanks Micha! Once again, CPAN to the rescue. But how do you find the right module???
As for this Hash::Merge package, it seems a cannon, and all I needed was to kill a mosquito… Regards to all, Meir From: [email protected] [mailto:[email protected]] On Behalf Of Micha Sent: יום ג 30 אוקטובר 2012 18:22 To: Perl in Israel Subject: Re: [Israel.pm] Importing values from a 2D hash into another 2D hash maybe: use Hash::Merge qw(merge); %combined_hash = %{ merge( \%combined_hash, \%added_hash ) }; Cheers, Micha On Tue, Oct 30, 2012 at 3:47 PM, Meir Guttman <[email protected]> wrote: Thank you Sawyer and Ran. Intriguing… But I was thinking about something akin to how one combines two simple hashes as: %combined_hash = (%combined_hash, %added_hash); (This of course overwrites same-key records, but in my application this is a “feature” and a bonus... J) My problem was that I was lost and couldn’t figure out how to deal with all these references to anonymous inner hashes. L Meir From: [email protected] [mailto:[email protected]] On Behalf Of sawyer x Sent: יום ב 29 אוקטובר 2012 21:07 To: Perl in Israel Subject: Re: [Israel.pm] Importing values from a 2D hash into another 2D hash Booya! On Mon, Oct 29, 2012 at 9:04 PM, Ran Eilam <[email protected]> wrote: Returning a new value instead of mutating the sub arguments: sub combine_values { my $old = shift; my $new = shift; return map {$_ => { %{ $old->{$_} }, %{ $new->{$_} || {} } }} keys %$old; } Ran _______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl _______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
_______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
