my %hash3_origin = ( 'key1' => [1, 2], 'key2' => [3, 4], 'key3' => [5, 6] ) ; my @keys3_0 = qw( key1 key1 key2 key2 key2 ) ; my @keys3_1 = qw( key2 key3 key3 key3 key3 ) ; my %hash3 ; my @keys3_origin = keys %hash3_origin ; @hash3{@keys3_origin} = ([0, 0]) x @keys3_origin ; foreach ( @keys3_0 ) { my $key = $_ ; $hash3{ $key }->[0] += $hash3_origin{ $key }->[0] ; } foreach ( @keys3_1 ) { my $key = $_ ; $hash3{ $key }->[1] += $hash3_origin{ $key }->[1] ; } print Dumper( \%hash3 ) ; __END__ $VAR1 = { 'key3' => [ 11, 28 ], 'key1' => $VAR1->{'key3'}, 'key2' => $VAR1->{'key3'} };