in reply to Re: Kindly let me know what exactly && does in Perl
in thread Kindly let me know what exactly && does in Perl
You're probably thinking of ||
If you replace && with || in the code, || would short-circuit on $y and $z, but not on $x.
Short-circuiting basically means to stop evaluating a logical expression once its outcome is known. For logical And, that means stop evaluating once the first false value is seen, for logical Or, stop once the first true value is seen.
Short-circuit behavior, especially Perl's behavior of returning the last evaluated value, can be useful for:
|
|---|