in reply to RE: Re: Scope of regular expression variables
in thread Scope of regular expression variables
$1 and $2 aren't localized within the if block -- unless the regex is also within the same enclosing block.$_ = "abcde"; if (/(.)(.)/) { # first two if (/(.)(.)$/) { print "inner: $1 $2\n"; } print "outer: $1 $2\n"; } print "outer: $1 $2\n";
(At least, that makes it more explicit.)
|
|---|