in reply to Regex match on implicit default variable ($_) in a script, not a one liner

Basic debugging checklist says to find out what perl thinks of your program use B::Deparse, like  perl -MO=Deparse,-p ...

So

$ perl -MO=Deparse,-p -wlne " ! /def/ and print qq{$_}; " BEGIN { $^W = 1; } BEGIN { $/ = "\n"; $\ = "\n"; } LINE: while (defined(($_ = <ARGV>))) { chomp($_); (/def/ or print("$_")); } -e syntax OK