Due to the low precedence of the ‘or’ operator, or3 parses as follows:
sub or3 {
my ($a,$b) = @_;
(return $a) or $b;
}
The usual advice is to only use the ‘or’ operator for control flow:
@info = stat($file) or die;
For more discussion, see the perl manual: http://perldoc.perl.org/perlop.html#Logical-or-and-Exclusive-Or
Related Contents:
- What’s the easiest way to install a missing Perl module?
- Why are Perl 5’s function prototypes bad?
- Why can’t Perl find my file that is in ClearCase?
- How is Perl’s @INC constructed? (aka What are all the ways of affecting where Perl modules are searched for?)
- How can I install a CPAN module into a local directory?
- Specifying file to process to Perl one-liner
- Doesn’t Perl include current directory in @INC by default?
- How can I require an optional Perl module if installed?
- Perl daemonize with child daemons
- How do I remove duplicate items from an array in Perl?
- Scalar vs List Assignment Operator
- When should I use the & to call a Perl subroutine?
- How do I compare two strings in Perl?
- How do I run a Perl script from within a Perl script?
- How can I parse dates and convert time zones in Perl?
- Which one is good practice, a lexical filehandle or a typeglob?
- How do you capture stderr, stdout, and the exit code all at once, in Perl?
- How can I check if a Perl array contains a particular value?
- Difference between &function and function() in perl [duplicate]
- How to fix a locale setting warning from Perl
- How do I read in the contents of a directory in Perl?
- Multiline search replace with Perl
- How can I pass command-line arguments to a Perl program?
- How do I efficiently parse a CSV file in Perl?
- How do you round a floating point number in Perl?
- Perl flags -pe, -pi, -p, -w, -d, -i, -t?
- How should I use the “my” keyword in Perl?
- Perl 5.20 and the fate of smart matching and given-when
- How can I generate all permutations of an array in Perl?
- Perl read line by line
- Perl subroutine arguments
- How does double arrow (=>) operator work in Perl?
- Why are Perl source filters bad and when is it OK to use them?
- Iterating hash based on the insertion order?
- How can I convert the stringified version of array reference to actual array reference in Perl?
- What does the function declaration “sub function($$)” mean?
- How can I manually interpolate string escapes in a Perl string?
- Why can’t I match my string from standard input in Perl?
- How to pass a variable from a child process (fork by Parallel::ForkManager)?
- What is the difference between my and local in Perl?
- How can I guess the encoding of a string in Perl?
- How do I fix this Perl code so that 1.1 + 2.2 == 3.3?
- How can I interact with ClearCase from Perl?
- What exactly does Perl’s “bless” do?
- How do I tell CPAN to install all dependencies?
- Which cpan installer is the right one? (CPAN.pm/CPANPLUS/cpanminus)
- What reasons are there to prefer glob over readdir (or vice-versa) in Perl?
- Converting relative path into absolute path?
- What does =~ do in Perl? [closed]
- Why are use warnings; use strict; not default in Perl?