Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Perl 5.17 change to use re 'eval' breaks Acme::EyeDrops

by dave_the_m (Parson)
on Apr 25, 2013 at 08:44 UTC ( #1030627=note: print w/ replies, xml ) Need Help??


in reply to Perl 5.17 change to use re 'eval' breaks Acme::EyeDrops

Shorn of its obfuscation, that code is equivalent to

'' =~ '(?{eval"print\"hello world\\n\""})';
Note that the pattern is within a string literal ('') rather than a pattern literal (//). The 5.17.x changes make it so that code blocks which don't need a 'use re eval' can appear only within pattern literals.

Dave.


Comment on Re: Perl 5.17 change to use re 'eval' breaks Acme::EyeDrops
Download Code
Re^2: Perl 5.17 change to use re 'eval' breaks Acme::EyeDrops (why?)
by tye (Cardinal) on Apr 26, 2013 at 06:17 UTC

    Thank you for that information.

    code blocks which don't need a 'use re eval' can appear only within pattern literals

    Why?

    - tye        

      Because I've changed it so that re code blocks are parsed now by the main perl parser, not by the regex engine calling back into the parser; e.g. /foo(?{ $x + 1 })/ is now parsed in the same manner that "foo$bar[$x + 1]" always has been. If it misses the parser and gets picked up later by by the regex engine (e.g. due to code appearing from external sources at runtime), then the engine will insist that 'use re eval' is in scope.

      This fixes lots of the bugs in re eval lexical scoping, while only breaking the occasional edge case. And it creates a simple understandable rule for when 'use re eval' needs to be in effect.

      It also means that the following, which formerly required 'use re eval', no longer does:

      $foo = 'bar'; /(?{...})$foo/

      Dave.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2014-12-17 21:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (34 votes), past polls