Nov 152010
What is the difference between || and or in Perl?
Answer:
In Perl, sometimes you can use both `||` and `or` to to do the same thing. But the main different is:
- or has very low precedence, which is useful for flow control
Example:
open FILE, $file or die("Cannot open $file"); # Work
open FILE, $file || die("Cannot open $file"); # Does not work , because it it same as the next statement
open FILE, ($file || die("Cannot open $file")); # Obviously not work