Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: (zdog) Re: Confused by a Conditional

by ZZamboni (Curate)
on Jun 09, 2001 at 22:06 UTC ( #87214=note: print w/ replies, xml ) Need Help??


in reply to (zdog) Re: Confused by a Conditional
in thread Confused by a Conditional

Note that if $key is a user-provided value, doing this is not a good idea. At the very least you would want to enclose the whole thing in an eval in case $key contains some characters that upset the match operator (for example, if $key contains **, the program will die with "nested *?+ in regexp"). In the worst case, $key could contain something that makes Perl execute arbitrary code. So for doing something like this, you have to make sure that $key is properly untainted.

Update: You could also use \Q, as in "string" =~ m/ \Q$key /

--ZZamboni


Comment on Re: (zdog) Re: Confused by a Conditional

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (22)
As of 2015-07-30 20:31 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 (273 votes), past polls