in reply to Lazy conditional, skips assignment.
I simplified your code to this (in a one-liner type of execution):
As you can see, $holdtime is not assigned to 1. The important point is the precedence between || and &&. && has a higher precedence than ||. So that the preceding code can be interpreted as:$ perl -e 'our $cookingcounter = 350883; > our $garlicbreadheadstart = 600; > our $ovenempty = 0; > > my $holdtime = 0; > if ( > !$ovenempty > || $test > && $holdtime = 1) > ) { > die sprintf "Main Dish or Appetizer Cooking: %d, hold for %d", $ +cookingcounter, $holdtime; > }' Main Dish or Appetizer Cooking: 350883, hold for 0 at -e line 11.
In short, if !$ovenempty is true, none of the rest of the code is ever executed, because:our $cookingcounter = 350883; our $garlicbreadheadstart = 600; our $ovenempty = 0; my $holdtime = 0; if ( !$ovenempty || ($test && $holdtime = 1) ) { die sprintf "Main Dish or Appetizer Cooking: %d, hold for %d", $co +okingcounter, $holdtime; }
- !$ovenempty evaluates to true,
- and that's enough, we won't care about conditions grouped in a conditional having a lower priority.
So that the rest of the code is not even executed.
|
|---|