![]() |
|
Just another Perl shrine | |
PerlMonks |
Re: AND ORby Zaxo (Archbishop) |
on May 14, 2006 at 06:14 UTC ( #549296=note: print w/replies, xml ) | Need Help?? |
Additional to what Tanktalus said. The logical operator pairs (&& and), and (|| or) only differ by their precedence. The spelled-out ones have extremely low precedence, while the symbolic ones are fairly high. These operators are "lazy evaluated". The or op will not evaluate its right-hand term if the left evaluated true. The and op will not evaluate its right-hand term if the left evaluated false. That makes the following possible. The logical operators can be used as concise forms of program flow control. That is often seen in error handling. An operation which returns true on success will skip an operation connected by or, so we write, to handle failure to open a file, for example. After Compline,
In Section
Seekers of Perl Wisdom
|
|