you can set up a small test: eg
Code:
$var = open(FILE,"<file") or print "cannot open"; here's my output: Code:
# ./test.pl |
From Perl docs ( http://perldoc.perl.org/perlop.html )
"Logical or and Exclusive Or Binary "or" returns the logical disjunction of the two surrounding expressions. It's equivalent to || except for the very low precedence. This makes it useful for control flow print FH $data or die "Can't write to FH: $!"; This means that it short-circuits: i.e., the right expression is evaluated only if the left expression is false. Due to its precedence, you should probably avoid using this for assignment, only for control flow. $a = $b or $c; # bug: this is wrong ($a = $b) or $c; # really means this $a = $b || $c; # better written this way However, when it's a list-context assignment and you're trying to use "||" for control flow, you probably need "or" so that the assignment takes higher precedence. @info = stat($file) || die; # oops, scalar sense of stat! @info = stat($file) or die; # better, now @info gets its due Then again, you could always use parentheses. " See last 2 examples here. Edit: re ghostdog's example above, I always use something like ... or print "Cannot open file <filename>: $!\n"; where $! is perl's built-in error code marker/special var (auto translates to error msg) |
All times are GMT -5. The time now is 08:10 AM. |