use XML::Simple; use Hash::Merge; my %config1 = %{XMLin ('file1')}; my %config2 = %{XMLin ('file2')}; my %newhash; Hash::Merge::set_behavior ('RIGHT_PRECEDENT'); *newhash = merge (\%config1, \%config2); XMLout (\%newhash, outputfile => "newfile", xmldecl => 1, rootname => 'config');