in reply to
Re^3: = rather than =~ ? (too brief?)
in thread = rather than =~ ?
$foo = $1 if /(foo)/; may very well be the expected behaviour in certain situations where we want to modify $foo if the match is successfull or leave it otherwise. Using it when declaring a variable is not desirable however. If there is no match, then $foo will not be
declared and any attempt to read the scalar later will result in a "variable not declared" error. Of course, this is why we use strict;. Without it, we won't get an error :) defined.
Basically, $foo = $1 if /(foo)/; should really only be used where we might otherwise do a $foo = /(foo)/ ? $1 : $foo; (which is just programatically ugly).
Update: Whoa, was I off base. Read the replies to this node to see the reason :)