perldoc perlop yields:
...roboticusC-style Logical Or
Binary "||" performs a short-circuit logical OR operation. That is, if the left operand is true, the right operand is not even evaluated. Scalar or list context propagates down to the right operand if it is evaluated.
The "||" and "&&" operators return the last value evaluated (unlike C's "||" and "&&", which return 0 or 1). Thus, a reasonably portable way to find out the home directory might be:
$home = $ENV{'HOME'} || $ENV{'LOGDIR'} || (getpwuid($<))[7] || die "You're homeless!\n";
In reply to Re^3: Default Hash Key
by roboticus
in thread Default Hash Key
by tford
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |