I often have a line like this at the beginning of my scripts:
@ARGV or die "Usage: blah\n";
... but I've seen:
@ARGV || die "Usage: blah\n";
Could someone explain the difference?
The only difference (other than readability) between "or" and "||" operators (as well as "and" and "&&") is the precedence. See perlop manpage: http://www.perldoc.com/perl5.8.0/pod/perlop.html
There's no difference between:
@ARGV or die;
and
@ARGV || die;
but there is a difference e.g. with assignment, which has lower precedence than "||" but higher than "or":
$x = shift or die; # means ($x = shift) or die; $x = shift || die; # means $x = (shift || die);
$x = shift || "default"; # OK - means $x = (shift || "default"); $x = shift or "default"; # wrong - means ($x = shift) or "default";
In the last example $x is never set to "default".
-zsdc.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]