You're on the right track, but not quite. You're looking over @file2 once and @file1 twice. You can combine the loops for @file1 into a for-loop and you'll be slightly better off.
Of course, "best" is a difficult word to work with. Personally, I'd use Set and go for the intersection for both and the differences for the ones missing.
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?