in reply to comparing 2 files

The best way to handle such things, in my experience, is always to sort the two files (or copies thereof) using a disk-based sort, then simply compare the two files sequentially.   It’s a practical strategy that dates back to before digital computers, and it’s “startlingly effective,” no matter what kind of data volume you might be dealing with.   Yes indeed, there are CPAN modules.