P is for Practical | |
PerlMonks |
Re^11: compare two text file line by line, how to optimiseby poj (Abbot) |
on Feb 28, 2016 at 16:55 UTC ( [id://1156385]=note: print w/replies, xml ) | Need Help?? |
Looks like your code had 2 loops, each counting to +6 million
But within the 6 million words, there are only few thousand different ones so your loops were checking the same word thousand of times more than required. By holding the unique words from file1 in a hash you don't have to loop through 6 million words every time to find a match with a word from file2 poj
In Section
Seekers of Perl Wisdom
|
|