in reply to Kindly let me know what exactly && does in Perl
See perlop: The ||, // and && operators return the last value evaluated (unlike C's || and &&, which return 0 or 1).
For $y and $z, the first operand is true, so && needs to look at the second operand to determine if both are true. The && for $x can short-circuit after seeing that the first operand is false, thus knowing the AND expression will be false.
As for your expected value of $y, remember that 0 is false, so you shouldn't expect the result of the operation to be a true value.
You're probably thinking of ||, which can short-circuit if the first operand is true.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Kindly let me know what exactly && does in Perl
by Anonymous Monk on Sep 07, 2014 at 15:10 UTC |