in reply to Re: Scope of regular expression variables
in thread Scope of regular expression variables
for which I get$_ = "abcde"; if (/(.)(.)/) { # first two if (/(.)(.)$/) { # last two, by your theory won't upset print "inner: $1 $2\n"; } # by your theory, should see first two again print "outer: $1 $2\n"; }
But if you add a block:inner: d e outer: d e
we do in fact get the expected:$_ = "abcde"; if (/(.)(.)/) { # first two { # ADDED if (/(.)(.)$/) { # last two, by your theory won't upset print "inner: $1 $2\n"; } } # ADDED # by your theory, should see first two again print "outer: $1 $2\n"; }
inner: d e outer: a b
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: Re: Scope of regular expression variables
by takshaka (Friar) on Aug 30, 2000 at 02:35 UTC | |
|
RE: RE: Re: Scope of regular expression variables
by Carl-Joseph (Scribe) on Aug 30, 2000 at 03:47 UTC | |
|
RE: RE: Re: Scope of regular expression variables
by chromatic (Archbishop) on Sep 16, 2000 at 02:15 UTC |