use strict; use Data::Dumper; %muthash = ( key1 => '1', key15 => '3', key150 => '1', ); %copyhash =( key1 => '1', key15 => '1', key140 => '1', ); %mergedhash = (); %mergedhash = map {$_=> $muthash{$_} + $copyhash{$_}; } (keys %muthash, keys %copyhash); print Dumper(\%mergedhash);