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

Re: If statement multiple conditions

by sundialsvc4 (Abbot)
on Mar 14, 2013 at 01:45 UTC ( #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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1023336]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2018-05-26 04:36 GMT
Find Nodes?
    Voting Booth?