I had a similiar problem just last week. matija recommends Algorithm::Diff, but it didn't do the Right Thing for me.
matija and Happy-the-monk recommend putting the values into a hash, which is excellent advice. The Perl Cookbook shows how, recipes 4.7 and 4.8.
Or (ta-da!) use List::Compare (http://search.cpan.org/~jkeenan/List-Compare-0.22/Compare.pm) which implements the hash-y code in a really, really usable way. I think you'll find that it will solve your problem in an elegant way. (It did mine!)