http://www.perlmonks.org?node_id=1023336


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!