On 7/3/07, Paul Johnson <[EMAIL PROTECTED]> wrote: snip
And, in this case, more accurate. Unless you know something the rest of us don't.
snip
The trinary operator (?:) returns the value of either the true or false portion depending on the conditional portion, so putting print in both the true and false portions is redundant. Also 0 is one of the 5ish false values* so !$var1 is the same thing** as $var1 == 0 and 1 is one of the infinite true values*** so $var2 is equivalent to $var2 == 1 so long as you are testing for truth rather than the specific value 1. #!/usr/bin/perl -l use strict; use warnings; my $var1 = 0; my $var2 = 1; print "should print hai:", !$var1 && $var2 ? "hai" : "bye"; $var1 = 1; print "should print bye:", !$var1 && $var2 ? "hai" : "bye"; $var2 = $var1 = 0; print "should print bye:", !$var1 && $var2 ? "hai" : "bye"; * The false values are empty list, empty string, undef, string containing only one zero, and any number -- but not string -- that is equivalent to 0 ** well, this is a little white lie because undef == 0 throws a warning when the warnings pragma is in effect, but that is the only difference. *** anything that is not false, i.e. all strings except the one character string "0", any reference, and any numeric value other than 0 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/