Another oddity: the problematic behavior seems to be associated with assignment to a freshly declared lexical:

c:\@Work\Perl\monks>perl -le "use warnings; use strict; ;; use Test::More 'no_plan'; use Test::NoWarnings; ;; note 'perl version: ', $]; ;; @_ = qw(a b c d e f g); ;; note 'assign to a fresh lexical'; ;; my @ra = (shift @_)[ 0, 0, 0 ]; is_deeply \@ra, [ 'a', 'a', 'a' ], '1st = (shift)[slice] to my @ra'; ;; @ra = (shift @_)[ 0, 0, 0 ]; is_deeply \@ra, [ 'b', 'b', 'b' ], '2nd = (shift)[slice] to @ra'; ;; note 'now another lexical'; ;; my @rb = (shift @_)[ 0, 0, 0 ]; is_deeply \@rb, [ 'c', 'c', 'c' ], '1st = (shift)[slice] to my @rb'; ;; @rb = (shift @_)[ 0, 0, 0 ]; is_deeply \@rb, [ 'd', 'd', 'd' ], '2nd = (shift)[slice] to @rb'; ;; @rb = (shift @_)[ 0, 0, 0 ]; is_deeply \@rb, [ 'e', 'e', 'e' ], '3rd = (shift)[slice] to @rb'; ;; done_testing; " # perl version: 5.014004 # assign to a fresh lexical not ok 1 - 1st = (shift)[slice] to my @ra # Failed test '1st = (shift)[slice] to my @ra' # at -e line 1. # Structures begin differing at: # $got->[1] = undef # $expected->[1] = 'a' ok 2 - 2nd = (shift)[slice] to @ra # now another lexical not ok 3 - 1st = (shift)[slice] to my @rb # Failed test '1st = (shift)[slice] to my @rb' # at -e line 1. # Structures begin differing at: # $got->[1] = undef # $expected->[1] = 'c' ok 4 - 2nd = (shift)[slice] to @rb ok 5 - 3rd = (shift)[slice] to @rb 1..5 ok 6 - no warnings 1..6 # Looks like you failed 2 tests of 6.
(These tests all pass for all other versions I have in captivity; see update to this reply.)


Give a man a fish:  <%-{-{-{-<


In reply to Re: Case where '( shift @_ )[ 0, 0 ]' returns only one value? by AnomalousMonk
in thread Case where '( shift @_ )[ 0, 0 ]' returns only one value? by rsFalse

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.