Another oddity: the problematic behavior seems to be associated with assignment to a freshly declared lexical:
(These tests all pass for all other versions I have in captivity; see update to this reply.)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.
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |