Yes, there are a lot of ways to write it correctly, and a lot of incorrect ways too. ;) The one you proposed should work fine. But I would use the lower precedence operators:
while( not ( $worker1Finished eq 'true' and $worker2Finished eq 'true' ) ) { # ... }
...to at least eliminate one set of parens. In fact, if my memory of the precedence tables serves me (which it may not), you could eliminate the other set of parens like this:
while( not $worker1Finished eq 'true' && $worker2Finished eq 'true' ) { # ... }
Because 'eq' is higher precedence than &&, and && is higher precedence than 'not', so eq binds first, && second, and 'not' last.
But the gods gave us 'until(){}' because it suited them to do so. While it's important to use caution when wielding negatives (and double negatives, etc.), it is useful sometimes. My preference in this case is to use it.
until( $worker1Finished eq 'true' and $worker2Finished eq 'true' ) { # ... }
Personal preference. But to me "until this and that keep looping" reads better than "while not both this and that keep looping."
Dave
In reply to Re^3: Short circuits in Logical AND (&&)
by davido
in thread Short circuits in Logical AND (&&)
by vishi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |