http://qs321.pair.com?node_id=861413


in reply to Comparing unordered but similar data files

Your use of eq is actually comparing the number of elements in each array, which is why you only see a failure if one file has more lines than the other.

If you're using Perl 5.10 or newer, you can achieve what you want using ~~ (the smart match operator) instead:-

if (@sorted ~~ @sorted2) {

If you're using Perl 5.8 or older, you'll need to compare the arrays element by element, an example of which you can find in perlfaq4 - How do I test whether two arrays or hashes are equal?.

    --k.