in reply to merge two hashes into one

c:\@Work\Perl>perl -wMstrict -MData::Dump -le "my %h1 = qw(foo 3 bar 99); my %h2 = qw(foo 5 bar 87); ;; die 'hashes unequal: merging invalid' if keys %h1 != keys %h2; ;; for my $k (keys %h1) { die qq{key '$k' not found: merging invalid} unless exists $h2{$k}; $h1{$k} += $h2{$k} } ;; dd \%h1; " { bar => 186, foo => 8 }

Update: Hey, isn't this a FAQ somewhere? Can't find it ATM.


Give a man a fish:  <%-{-{-{-<