Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: IF and some conditions

by jhourcle (Prior)
on Jun 02, 2005 at 11:54 UTC ( [id://462865]=note: print w/replies, xml ) Need Help??


in reply to IF and some conditions

#NOT OK print "OK\n" if ($test =~ /[753]/);

I think you were on the right track with why the last one wasn't good. Try with any of the following input, and you'll see why: 50, 72, 39, 256. You want to anchor your regexes when testing for equality:

print "OK\n" if ($test =~ /^[753]$/);

Update: I can't spell.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-19 01:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found