Re: RE: [Boston.pm] I want a 'compile time' check on missing parens in regex

2004-07-27 Thread Jeremy Muhlich
On Tue, 2004-07-27 at 12:54, Daniel Allen wrote: > LINE: while (defined($_ = )) { > /(\d+)/; > print "$1 "; > } > continue { > #print $_; > } The continue interposes another block into the loop. According to perlre as quoted by Steve below, $1 et al. are scoped until the end of the

RE: [Boston.pm] I want a 'compile time' check on missing parens in regex

2004-07-21 Thread Tolkin, Steve
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.

RE: [Boston.pm] I want a 'compile time' check on missing parens in regex

2004-07-21 Thread Greg London
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_parentheses_not_capturing I suppose I should make a note to include some s/// examples... note to self: self, add some s/// examples. --

Re: [Boston.pm] I want a 'compile time' check on missing parens in regex

2004-07-21 Thread Greg London
Ron Newman said: >>If I intend to write something like >>s/([ab])c/$1c/; > That's not possible in general, because there could legitimately be a $1 left > over from a previous regex match. the /$1c/ will only get hit if the /([ab])c/ part matches, so if a substitution occurs, $1 will always be

RE: [Boston.pm] I want a "compile time" check on missing parens in regex

2004-07-21 Thread Tolkin, Steve
Summary: What is the scope of $1 and when does it get reset? Details: Thanks for the reply, Ron. It indicates that I understand this even less than I thought. What are the rules for "remembering" a previous value of $1 (and the other numeric variables set by pattern matching)? In the program

Re: [Boston.pm] I want a "compile time" check on missing parens in regex

2004-07-21 Thread Ron Newman
>If I intend to write something like >s/([ab])c/$1c/; >but accidentally omit the parentheses and write >s/[ab]c/$1c/; >I get a run time error message -- assuming >the pattern matches the input data. >But if the test data does not expose >this bug I might not find out about it until later. > >Is

[Boston.pm] I want a "compile time" check on missing parens in regex

2004-07-21 Thread Tolkin, Steve
If I intend to write something like s/([ab])c/$1c/; but accidentally omit the parentheses and write s/[ab]c/$1c/; I get a run time error message -- assuming the pattern matches the input data. But if the test data does not expose this bug I might not find out about it until later. Is there any