in reply to match two files
This is a FAQ. See perlfaq4 on How do I compute the intersection of two arrays?.
Your code is slow because for every item in @lines1 it looks at all items in @lines2. If you precompute a lookup table ("hash", in Perl data structures) for the items in @lines2, you can find the items in @lines2 much faster.
|
|---|