To compare XML sources requires a fair bit more than comparing the lines. The first approach that comes to mind is to load each file into a tree, using one of the treebuilding CPAN modules such as XML::Twig, then traversing the two trees to build e.g. a single hash of array where each hash value is an array of what is compared for a given tag. Then a second pass through that merged structure to do the actual comparison. (I can't be more specific about the comparison without knowing what is being compared).