Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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.


Comment on Re: If statement multiple conditions
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
Node Status?
node history
Node Type: note [id://1023336]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-11-28 05:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (193 votes), past polls