reposting answer from https://www.perlmonks.org/?node_id=127848
Paste following into a perl script
use strict;require 5.000;use Data::Dumper;use XML::Simple;use Hash::Merge;my $xmlFile1 = shift || die "XmlFile1\n";my $xmlFile2 = shift || die "XmlFile2\n";my %config1 = %{XMLin ($xmlFile1)};my %config2 = %{XMLin ($xmlFile2)};my $merger = Hash::Merge->new ('RIGHT_PRECEDENT');my %newhash = %{ $merger->merge (\%config1, \%config2) };# XMLout (\%newhash, outputfile => "newfile", xmldecl => 1, rootname => 'config');print XMLout (\%newhash);