in reply to In what order is a compound IF evaluated?
If $x ='One', then the tests for $y and $z will be skipped, it does not matter what they are, the result is a big False. If you arrange the clauses in your compound 'if' in the order (roughly) of frequency, you will get the most speed out of it.if (($x eq 'c'}&&($y eq 'd')&&($z eq 'e')){ }
That said, from a maintenance point of view, compound booleans are a pain to muck with unless the original author did something nice with the indentation. For example --
I much prefer to cope with a switch statement or a cascade of if/elsif/else's when I have to trouble shoot some old code. It make the logic a bit clearer (to my mind), and makes adding another condition much easier.if ( ($x eq 'a') && ($y eq 'b') && ($z eq 'c') ) { }
----
I Go Back to Sleep, Now.
OGB
|
|---|