in reply to Re: Re: Trying to count the captures in a compiled regular expression
in thread Trying to count the captures in a compiled regular expression
Security alert: that will run code in (??{ }) / (?p{ }).
Maybe something like this instead?
Also, note that you have to add a () set and then subtract it from the count to be able to distinguish between 0 captures and 1 capture.$regex = qr:(??{print "look ma, no rm -rf /\n"}):; $captures = (() = ""=~/(|$regex)/) - 1;
|
---|
In Section
Seekers of Perl Wisdom