http://www.perlmonks.org?node_id=11137317


in reply to Re^4: Is it safe to use external strings for regexes?
in thread Is it safe to use external strings for regexes?

> just made it smarter ... without needing the "use re 'eval'":

hm, we seem to be talking about different things

please compare these threads

They show that concatenating literal strings to form an eval group used to work out of the box without use re 'eval' .

Both examples don't include any variables but rely on concats aka .

In detail: Some optimizer converted this

into this at compile time without complaining. Now it requires use re "eval"

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^6: Is it safe to use external strings for regexes?
by dave_the_m (Monsignor) on Oct 08, 2021 at 07:01 UTC
    hm, we seem to be talking about different things
    I thought we were talking about using strings obtained from an external source (such as a file or DB) as a regex, and whether the (?{...}) feature could be exploited in that case. The example you gave of concatting two halves of a regex still requires the code to be literal in the source (albeit split) to not need 'use re eval' in the src code, even prior to 5.18.0.

    Dave.

      As I said, I'm thankful that your change rules out

      ''=~ ( '(?{B' . 'EGIN{print "owned"}})' )

      to happen.

      Like this I have a chance to statically check for BEGIN or use re before running perl -c

      (sorry eyepopslikeamosquito :)

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery