Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Security Alert: Re: Re: Re: Trying to count the captures in a compiled regular expression

by ysth (Canon)
on May 03, 2004 at 06:01 UTC ( #349925=note: print w/ replies, xml ) Need Help??


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?

$regex = qr:(??{print "look ma, no rm -rf /\n"}):; $captures = (() = ""=~/(|$regex)/) - 1;
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.


Comment on Security Alert: Re: Re: Re: Trying to count the captures in a compiled regular expression
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2015-07-29 18:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (267 votes), past polls