in reply to Grep matches all elements if compiled regex is passed as EXPR
The following works:
grep $_=~$re, ...
Your problem is unrelated to grep. In
if (/re/ ) { ...a... } if ($re ) { ...b... } if (/$re/ ) { ...c... } if ($_=~$re ) { ...d... } if ($_=~/$re/) { ...e... }
...b... will always be executed if $re contains a compiled regexp. Others have already explained why.
|
|---|