Patrick's answer of <$regex-interpolation> is the one I'd use.

Although it checks a few possibly malicious things it doesn't catch
everything:
https://rt.perl.org/Public/Bug/Display.html?id=131079

On Fri, May 12, 2017 at 5:11 PM Andreas Mueller <
andreas.muel...@biologie.uni-osnabrueck.de> wrote:

>   IMHO  it is a security and speed issu
>
>   I switched it of with a pragma like this:
>
>     use MONKEY-SEE-NO-EVAL;
>     my $match = EVAL "/$m/";
>
>     if $test_string ~~ $match { say 'yea' }
>
>
>   Andreas
>
> On 11.05.17 10:32, Sean McAfee wrote:
> > I've been searching for how to parse a string into a regex, like qr/$str/
> > does in Perl 5, but so far without success.
> >
> > At first I assumed, by analogy with .Str, .List, etc, that I could call
> > .Regex on a string, but this is not the case.
> >
> > On IRC's #perl6 I learned about the <$str> construct, which doesn't
> really
> > create a new regex, but keeps a reference to the string around, with some
> > (to me) surprising semantics:
> >
> > my $str = 'foo';
> > my $re = rx/<$str>/;
> > $str = 'bar';
> > 'foo' ~~ $re;  # no match
> >
> > Still, it's *almost* sufficient for my needs, except that for the
> purposes
> > of a golfing challenge I'm working on, I want to parse the argument to a
> > WhateverCode object into a regex, but this:
> >
> > map rx/<*>/, <a b c>;
> >
> > ...rather predictably doesn't work.
> >
> > So, is there in fact any way to simply parse a string into a brand-new
> > Regex object?
>
> --
> Andreas Müller - Raum: 35/114b - Tel: 2875
>

Reply via email to