Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Detect * in arguments

by kennethk (Abbot)
on Jul 10, 2015 at 18:03 UTC ( [id://1134208]=note: print w/replies, xml ) Need Help??


in reply to Detect * in arguments

Code is worth 1000 words; please include input, output and code (or pseudocode) for future questions. See How do I post a question effectively?

Finding out whether a string contains a certain character can be done with index or regular expressions. In your case, maybe your check would look like:

if (index($args, '*') != -1) { die "No * are allowed.\n" }
or maybe you'd strip it using
$args =~ s/\*//g;
If these don't fit the bill, provide more algorithmic clarity, and I can be more helpful.

Update: Or do you mean the shell is expanding the '*' metacharacter before it gets fed to your code? In this case, your code never sees the asterisk, and the hassle in protecting the user from themself is almost assuredly not worth your time.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-23 12:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found