I wonder if you realise exactly what it is that you are testing with this construct? :)
use strict; use warnings; $" = '+'; for( ['a', 'b'], [1, 2], [0, 1], ['a', 'b'], [undef, undef], [1, undef], [undef, 1], [ ], ) { print "\@\$_ is @$_\n"; (my ($foo, $bar) = @$_) || print "I would die here\n"; print "\n"; }
You see, once you actually treat an array as a container of a list, rather than treating it as a list of scalar elements, then all of a sudden it becomes clear what he was testing for. A list with two undefined elements is not an empty list; it is a list with two undefined elements. In real world examples, instead of @$_ one would be using a function call (as the OP eventually demonstrated in his other post), much like the common while(my ($k, $v) = each %hash) { } idiom. This will not abort looping on pairs such as '' => undef because that is not an empty list - it will continue running until, when each reaches the end of the hash, it receives an actual empty list.

Makeshifts last the longest.


In reply to Re^2: question about || operator and list context by Aristotle
in thread question about || operator and list context by markjugg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.