On Sun, Mar 10, 2013 at 12:48:16AM +0000, Dave Mitchell wrote: > However, I would expect something like the following *should* work and be > safe, but it doesn't: > > use re 'eval'; return qr/(?{ $RGP::Success = 1 })$$re/; > > And as you pointed out, a 'use re eval' even in the scope of the main > qr/foo/ doesn't turn off the fatal error. So there's definitely something > there needing more work. The branch smoke-me/davem/re_overload, currently being smoked and shortly to be merged into blead, should fix this. If the following change is made to your test script: --- /tmp/rgtest.pl.orig 2013-04-11 10:28:53.879421869 +0100 +++ /tmp/rgtest.pl 2013-04-11 10:31:57.510778815 +0100 @@ -18,7 +18,7 @@ package RGP; use overload q{""} => sub { my $re = shift; - return '(?{ $RGP::Success = 1 })' . $$re; + return qr/(?{ $RGP::Success = 1 })$$re/; }, fallback => 1; } then it passes both tests when using my new branch. To make it still work on 5.16.x and earlier, you also need a use re eval: - return '(?{ $RGP::Success = 1 })' . $$re; + use re 'eval'; + return qr/(?{ $RGP::Success = 1 })$$re/; which is harmless, but unnecessary after my fix to blead. I haven't tried fixing up Regex::Grammars to see if it works, since it's too complex for a cursory glance and fix-up. I see lots of places in the code where it returns strings containing '(?{', but I don't know how practical it would be to convert all those to return qr//'s instead. -- Gravity is just a theory; teach Intelligent Falling in our schools! http://www.theonion.com/content/node/39512Thread Previous | Thread Next