if ($_ = (m/^[\$]\w/)) {
Solution pointed out below. This is an assignment (using =) clobbering $_ with an empty array the true/false result. An assignment of an undefined thing evaluates to false every time. Similar to if ($_ = ()) or if ($_ = undef).
Update - because I was curious:
perl -MO=Deparse,-P -e 'if($_ = (m/foo/)) { print 'hi' }' if ($_ = /foo/) { print hi $_; } -e syntax OK
A little more insight.
update 2- corrected ty
In reply to Re: If statement not working
by perlfan
in thread If statement not working
by catfish1116
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |