If the first clause of an AND is false, or if the first clause of an OR is true, there's no reason for perl to evaluate the right side of the expression. Side effects in expressions often have issues like this.
In your case, it looks like you're just trying to pack too much stuff in a single conditional. When I look it over, I wonder what the heck it's doing. Yeah, I can figure it out, but I'd rather work on code that I can read, rather than decipher. Breaking it down into discrete units will make it simpler to read, and easier for you to debug, as well!
Update: I think your code is probably trying to do this (roughly):
our $cookingcounter = 350883; our $garlicbreadheadstart = 600; our $ovenempty = 0; sub hold_time { my $cookingcounter = shift; return 0 if $ovenempty and !$test; my $holdtime = $cookingcounter + 60*90 - 356400; return $holdtime if $holdtime > 0; $holdtime = $cookingcounter + ($garlicbreadstart - 60 * (60+15)) - + 356400; return $holdtime if $holdtime > 0; return 0; }
Update 2: After seeing hdb's response, I adjusted my code so it wouldn't return in test mode even when the oven is empty.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: Lazy conditional, skips assignment.
by roboticus
in thread Lazy conditional, skips assignment.
by cheako
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |