in reply to @- Bug on the loose, lets isolate it
When I added "$&" to the print statement, I always got the right answer, so I would assume the problem lies with the optimization that applies when "$&" is not used.
Presumably, when perl compiles a script that does not use "$&", part of what is being optimized out involves allocating some resource that is needed to store or set @-.
(updated to make last paragraph easier to read)
Another update: after seeing davido's doubts about my conclusion, and even after replying to that, I have to admit he may have a point -- I tried one other mod to the OP script: add parens around "b" in the regex, and the problem goes away. So I'll guess that there is some logic that is invoked by the need to do a capture, or the need to handle $&, that will not be invoked when neither need arises, and (for some, maybe most, perl builds) this causes the problem with using @-. But that's just a guess, in hopes that it might help the perl source-code wonks to nail this thing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: @- Bug on the loose, lets isolate it
by davido (Cardinal) on May 30, 2005 at 07:32 UTC | |
by graff (Chancellor) on May 30, 2005 at 07:51 UTC |