June 2002
Beginner
759 pages
80h 42m
English
Perl provides the && (logical AND) and || (logical OR) operators. They evaluate
from left to right testing the truth of the statement.
Example | Name | Result |
|---|---|---|
| And | |
| Or | |
For example, an oft-appearing idiom in Perl programs is:
open(FILE, "somefile") || die "Cannot open somefile: $!\n";
In this case, Perl first evaluates the open function. If the value is true
(because somefile was
successfully opened), the execution of the die function is unnecessary and is
skipped.
Perl also provides lower-precedence and and or operators that are more
readable.