|more useful options|
Re: or orby ahunter (Monk)
|on Jul 08, 2000 at 15:53 UTC||Need Help??|
They differ in precedence, and are otherwise the same. This means that if you write:
Perl evaluates this:
This changes what gets assigned to $a, and can also change the context of a statement (from perlop):
This occurs because die is in scalar context, (so || is great for obfuscation!). || is also appropriate where you want to cause the rightmost value to get assigned. That is:
Would assign $c to $a if $b was false, otherwise it would assign $b to $a. Whereas:
Would not assign $c to $a when $b was false! In scalar context, using || for dieing is fine, but you'll run into trouble with things where context is important. or is almost always what you mean in these cases.
If you still don't believe me, try this:
$a will be 0, and $b will be 1.