in reply to compare initial

The operation that you describe is called "symmetric difference" of sets. A quick search of CPAN finds Set::Tiny. It provides links to several other modules which you may prefer.
Bill