Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Case where '( shift @_ )[ 0, 0 ]' returns only one value?

by AnomalousMonk (Archbishop)
on Jan 14, 2019 at 22:30 UTC ( [id://1228557]=note: print w/replies, xml ) Need Help??


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

A possibly helpful test:

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); note 'raw print list context shift: ', (shift @_)[ 0, 0, 0 ]; ;; @_ = qw(a b c); ok 'aaa' eq join('', (shift @_)[ 0, 0, 0 ]), 'joined shift'; ;; @_ = qw(a b c); my @ra = (shift @_)[ 0, 0, 0 ]; is_deeply \@ra, [ 'a', 'a', 'a' ], 'assigned shift'; ;; @ra = ('x', 'y', 'z')[ 0, 0, 0 ]; is_deeply \@ra, [ 'x', 'x', 'x' ], 'assigned list'; ;; done_testing; " # perl version: 5.014004 # raw print list context shift: aaa ok 1 - joined shift not ok 2 - assigned shift # Failed test 'assigned shift' # at -e line 1. # Structures begin differing at: # $got->[1] = undef # $expected->[1] = 'a' ok 3 - assigned list 1..3 ok 4 - no warnings 1..4 # Looks like you failed 1 test of 4.

Update: The problem seems to have been localized between about versions 5.14.x and 5.18.x inclusive so the following may be irrelevant, but just for the heck of it, the code above passes all tests for ActiveState 5.008009 and Strawberries 5.010001 and 5.012003, all running under Windows 7.


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1228557]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-20 12:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found