Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Multiple numeric not or compare in if statement

by hippo (Bishop)
on Jul 02, 2020 at 09:02 UTC ( [id://11118797]=note: print w/replies, xml ) Need Help??


in reply to Multiple numeric not or compare in if statement

You have good answers already so I'll merely point out 2 things which might make things a little easier for you in general.

Did you know that the || operator has lower precedence than either == or !=? This means that all your inner brackets can go and you can write your conditionals like this:

if ($a == 3 || $a == 77 || $a == 8)

Further, since not has lower precedence than && you could even write the negated one as

if (not $a != 3 && $a != 77 && $a != 8)

Finally, $a and $b are special variables (see perlvar) which means that you would be best to avoid them even in an SSCCE. I'd recommend starting from the other end of the alphabet if you want to use single-character names.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-03-29 11:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found