Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: Spurious re 'eval'; warning ?

by bsb (Priest)
on Aug 24, 2003 at 12:58 UTC ( [id://286186]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://286186]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-20 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found