Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^7: Simple comparison of 2 files

by Marshall (Canon)
on Jul 27, 2016 at 20:17 UTC ( [id://1168680] : note . print w/replies, xml ) Need Help??


in reply to Re^6: Simple comparison of 2 files
in thread Simple comparison of 2 files

Reading file1 into memory doesn't save anything. Reading file2 into memory does. The "expensive" operation is the line by line text read of the input file. Saving the split from File1 is an idea, but not necessary since each line from File1 need only be read and dealt with once as per my code.

Replies are listed 'Best First'.
Re^8: Simple comparison of 2 files
by pryrt (Abbot) on Jul 27, 2016 at 20:53 UTC

    Yeah, I thought of that after posting my second code... but I saw you'd already posted code like that, so didn't bother with another update/post.

    As a suggestion to Q.and, if using Marshall's code, I'd recommend picking the shorter file for "file2" and the longer file for "file1" -- it uses the least memory to store file2, but still requires only len(file1)+len(file2) line reads.