use strict; use warnings; use Hash::Merge; use Data::Dumper; my %hash1 = ( this => 1, that => 2, the => 3, other => 4 ); my %hash2 = ( those => 1, them => 2, thine => 3, other => 42 ); my %merged = %{ Hash::Merge->new('RETAINMENT_PRECEDENT')->merge( \%hash1, \%hash2 ) }; print Dumper \%merged;