in reply to Re: Spurious re 'eval'; warning ?
in thread Spurious re 'eval'; warning ?

What are you trying to do with your code?

I'm just playing around.

Returning a qr// regex is a work around.

I read perlre and re, and I consider "(?{1})" a valid return value. You can use other strings without a problem:

$ id|perl -nle 'print /( (??{ q[uid=\d+] }) )/x' uid=1000
This snippet from perlre doesn't specify a regex ref or string (although it is pretty vague). The example which follows in the man page uses a recursive qr// definition (so does return a qr// object).

From perlre:
(??{ code })
... The result of evaluation is considered as a regular expression and matched as if it were inserted instead of this construct.

Replies are listed 'Best First'.
Re: Re: Re: Spurious re 'eval'; warning ?
by CombatSquirrel (Hermit) on Aug 24, 2003 at 15:01 UTC
    My apologies, seems as though you were right. However, I found an interesting section in perl5005delta:
    %s: Eval-group not allowed at run time
    (F) Perl tried to compile a regular expression containing the (?{ ... }) zero-width assertion at run time, as it would when the pattern contains interpolated values. Since that is a security risk, it is not allowed. If you insist, you may still do this by explicitly building the pattern from an interpolated string at run time and using that in an eval(). See perlre/(?{ code }).
    Perl just doesn't seem to like what you're doing and stops it ;-).
    Hope this helps.
    Cheers, CombatSquirrel.

    Update: fixed typos.

      I noted elsewhere that it was probably wrong of perl to *not* throw an error when bsb prepended the 'qr' onto the internal regex. So you're exactly right.