in reply to Re^2: Multiple uses of (?{ code }) do not appear to be called
in thread Multiple uses of (?{ code }) do not appear to be called

The only way to fix this is to take the Perl 6 approach and clean up the compilation semantics of regexes. All of these hacks are a direct result of trying to treat regexes as strings rather than as a real minilanguage. Interpolating variables into regexes prior to compilation is simply wrong. It destroys any semblance of lexical scoping for both variable bindings and error message location. If I were going to fix this in Perl 5, I'd make a lexically scoped pragma to compile regexes immediately with sane variable bindings to avoid all this two-pass compilation bogosity. Any other approach is just bandaids.
  • Comment on Re^3: Multiple uses of (?{ code }) do not appear to be called

Replies are listed 'Best First'.
Re^4: Multiple uses of (?{ code }) do not appear to be called
by demerphq (Chancellor) on Dec 31, 2006 at 12:37 UTC

    Maybe I'm not seeing this properly, do you mean the issue of /$foo/ where $foo is a string? If so, its not clear to me how changing that makes the issue of rebinding compiled code into the pad of its usage context any easier.

    I can see how changing how variable interpolation is handled in regexes would make for a lot more flexibility in other respects, but its not clear how it helps the immediate issue of this thread... Can you explain a bit more please?

    ---
    $world=~s/war/peace/g