Juerd has asked for the wisdom of the Perl Monks concerning the following question:
If I make $acc lexical, which is what I want, the regex no longer matches the same string that does match when it is a global variable. Even if it's declared before any assignment (my $acc; $acc = qr/.../;).my $inlinetag = do { our $acc = qr/(?> \{ (?: (?> \\. | [^\\{}]+ | (??{ $acc }) ) )* + \} )/x; qr/ \{ (\w+): ( (?: (?> \\. | [^\\{}]+ | (??{ $acc }) ) )* +) \} /x; };
Because of this, I suspect that (??{ $variable }) doesn't play the normal Perl scoping game. If it were evaluating the variable when used, it should die (because that scope has no $acc), right?
Is Perl passing by name here? Why does strict not help me out here? :)
- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (??{ lexical variable })
by jryan (Vicar) on Dec 03, 2002 at 09:43 UTC | |
by Juerd (Abbot) on Dec 03, 2002 at 14:45 UTC | |
|
Re: (??{ lexical variable })
by Zaxo (Archbishop) on Dec 03, 2002 at 09:01 UTC | |
by Juerd (Abbot) on Dec 03, 2002 at 09:09 UTC |