$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.)
In reply to RE: RE: Re: Scope of regular expression variables
by chromatic
in thread Scope of regular expression variables
by FauxPasIII
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |