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 where I discovered the problem I have a bunch of
regexes, and so there could have been a value for $1 in effect.
But I got a warning message anyway.
Why wasn't that earlier value of $1 used?
Or was I used, and I only got the warning where there wasn't a value for
$1.  

Does the zero length string (aka null string) act as a previous value of
$1?


Thanks,
Steve

-----Original Message-----
From: Ron Newman [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 21, 2004 11:52 AM
To: Tolkin, Steve
Cc: [EMAIL PROTECTED]
Subject: Re: [Boston.pm] I want a "compile time" check on missing parens
in regex


>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 way to get a "compile time" check?

That's not possible in general, because there could legitimately be a $1
left
over from a previous regex match.

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

Reply via email to