($a,$b) = ( qw/a b/ || die );
Note that the || gets to be evaluated first. Since the boolean logic operators force scalar context on their left hand operand, which in this case is a list, you get what a list returns when coerced into scalar context: its last element. This is the string b here. Because it is is a true value, it shortcircuits the or-operator and so prevents die from being called. Now we get to the assignment, with just a single value in hand. The $a slurps it up, and $b is left with nothing to take.
By changing the order of evaluation with an extra pair of parens, you can make sure the or-operator doesn't coerce the wrong thing into scalar context - just like you did in your case #1.
Makeshifts last the longest.
In reply to Re: question about || operator and list context
by Aristotle
in thread question about || operator and list context
by markjugg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |