OK, here is the answer:
http://www.perldoc.com/perl5.6.1/pod/perlre.html says:
The numbered variables ($1, $2, $3, etc.) and the related punctuation
set ($+, $&, $`, and $') are all dynamically scoped until the end of the
enclosing block or until the next successful match, whichever comes
first. 

and 5.8.4 is the same except adding $^N (whatever that is).

So it is not possible in Perl 5.

Note that these numbered variables are somewhat like
global variables, and go do "action at a distance".

Is there going to be a way in perl 6 to control this better?


Steve

-----Original Message-----
From: Greg London [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 21, 2004 12:30 PM
To: Tolkin, Steve
Cc: [EMAIL PROTECTED]
Subject: RE: [Boston.pm] I want a 'compile time' check on missing parens
in regex



Tolkin, Steve said:
> What is the scope of $1 and when does it get reset?

here's a start:
http://www.greglondon.com/iperl/html/iperl.html#20_5_2_Capturing_parenth
eses_not_capturing

I suppose I should make a note to include some s/// examples...

note to self: self, add some s/// examples.

-- 
"Impatient Perl"
A GNU-FDL training manual for the hyperactive.
Free HTML/PDF downloads at greglondon.com/iperl
Paperback/coilbound available for $8.50+s&h

_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to