Oh, hang on a second, there was a valid reason why I wanted RegExp, actually, I forgot.
grep will still search the whole array @words, right?
My original code terminates as soon as it fails to match one word in the array which is what I wanted as the file is huge. Ok, it's not the best code at all, but it doesn't have to search the entire array every time.
I haven't benchmarked to check yet, but I guess grep might take longer.
I was hoping for a RegExp that stopped its search on a mismatch so I think your second solution might be faster, I will check.
Thanks!
Comment on Re^2: Need RegExp help - doing an AND match