|No such thing as a small change
Re: nested loops to compare 2 files is only looping a limited number of times.by si_lence (Deacon)
|on Jun 23, 2009 at 13:37 UTC
As noted above by SuicideJunkie you don't start from the beginning of the second file for each pass trough the outer loop, i.e. for each line of file1.
If your second file is not too big (compared to memory available) I would suggest to read the second file into a hash before the first loop and then loop through file1 and look for matches. You only need one loop then and not the two nested ones.