in reply to Comparing 1 array that matches in 2nd array
Kudos to frozenwithjoy for spotting the $_ collision!
A few other things, the '.' (dot) is a special character inside of regular expressions. You probably need to wrap your match in \Q and \E. Additionally, no matter how many times your grep matches, $theline, being a simple scalar variable, will only hold ONE element from the list that grep returns. It's also not necessary to wrap $theline in quotes. Why interpolate when all you want to do is push a simple scalar variable onto an array.
Is it possible that $theline is supposed to be @theline, so that you capture the entire list returned by grep, and push it all onto @thelist on each iteration? Capturing the return value of grep, in list context, but storing it in a scalar seems to me to be a big red flag.
Updated to acknowledge frozenwithjoy's nice catch.
Dave
|
|---|