Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: If statement multiple conditions

by sundialsvc4 (Abbot)
on Mar 14, 2013 at 01:45 UTC ( [id://1023336]=note: print w/replies, xml ) Need Help??


in reply to If statement multiple conditions

There are a couple of things that I do “routinely,” partly (but also, specifically) to guard against those WTF?!?! situations ...

First, in every script, I use use strict; use warnings;.   If you’ve omitted these, add them, run it again and see what happens.

Second, I will either use nested-if statements, or, when doubling up several conditions, I put each one in a separate set of parentheses whether I think I need them or not.

I candidly confess that I intentionally do not use “smart matching” (~~) either, although I won’t say that you should or shouldn’t.   I just prefer code that says as plainly as possible (to my feeble old brain) what it means, versus code that says what it says and depends on context to provide what it means.   If I have to read several paragraphs of perldoc perlsyn to fathom what something means, and to be warned that Perl-6 will be different, I don’t do it that way.

Replies are listed 'Best First'.
Re^2: If statement multiple conditions
by kbone (Novice) on Mar 14, 2013 at 02:50 UTC

    Thanks for the reply!

Log In?
Username:
Password:

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

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

    No recent polls found