in reply to Re^3: Case where '( shift @_ )[ 0, 0 ]' returns only one value?
in thread Case where '( shift @_ )[ 0, 0 ]' returns only one value?

This behavior appears somewhere between versions 5.12.3 and 5.14.4, but a quick scan of the deltas (update: between these versions) shows no justification for it. (Update: All code run under Windows 7.)

c:\@Work\Perl\monks>perl -wMstrict -le "print 'perl version: ', $]; ;; use Data::Dumper; ;; @_ = qw( a b c ); print( ( shift @_ )[ 0, 0, 0 ] ); ;; @_ = qw( a b c ); my @A = ( shift @_ )[ 0, 0, 0 ]; print Dumper \@A; ;; @A = ( 'x', 'y', 'z' )[ 0, 0, 0 ]; print Dumper \@A; " perl version: 5.012003 aaa $VAR1 = [ 'a', 'a', 'a' ]; $VAR1 = [ 'x', 'x', 'x' ]; perl version: 5.014004 aaa $VAR1 = [ 'a', undef, undef ]; $VAR1 = [ 'x', 'x', 'x' ];
Version 5.14 is the latest I can access ATM.


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

Replies are listed 'Best First'.
Re^5: Case where '( shift @_ )[ 0, 0 ]' returns only one value?
by stevieb (Canon) on Jan 14, 2019 at 21:49 UTC

    Nice catch AnomalousMonk, but it still breaks for me on 5.18 per OP's statement above:

    c:\repos\berrybrew>perl -le "@_ = qw( a b c ); @A = ( shift @_ )[ 0, 0 + ]; print @A" a c:\repos\berrybrew>perl -v This is perl 5, version 18, subversion 4 (v5.18.4) built for MSWin32-x +64-multi-thread

    I'm having some issues (per CB mention) with fetching versions on my Unix machines with perlbrew available, so all I can test on is Windows currently.