I'm not exactly sure either. I attempted to write some Test scripts. Getting only as far as comparing a couple of variations.
heres two scripts that start out looking to compare list and scalar context asignment. I'm not sure they have picked up what you are viewing, but could possibly get there?
A B my @x @y Scalar Context
use strict; use warnings; use feature qw'say state'; use diagnostics -verbose; #use Test::More test=>1; A B my @x @y Scalar Context my @x; my @y; if( ( fork() ) == 0 ){ if( ( fork() ) == 0 ){ say 'A: scalar context'; @x ? do{say 'A @x not empty'} : do{say 'A @x empty'}; my $s = shift @x; @x ? do{say 'A $s = shift @x; @x not empty'} : do{say 'A $s = shif +t @x; @x empty'}; defined $s ? do{say 'A defined $s'} : do{say 'A undefined $s'}; print "\n"; say 'A: scalar context'; @y ? do{say 'A @y not empty'} : do{say 'A @y empty'}; my $u = splice( @y,0,1 ); @y ? do{say 'A $u = splice @y; @y not empty'} : do{say 'A $u = spl +ice @y; @y empty'}; defined $u ? do{say 'A $u = splice @y; defined $u'} : do{say 'A $u + = splice @y; undefined $u'}; print "\n"; }else{ say 'B: scalar context'; undef @x; @x ? do{say 'B undef @x; @x not empty'} : do{say 'B undef @x; @x e +mpty'}; my $t = shift @x; @x ? do{say 'B $t = shift undef @x; @x not empty'} : do{say 'B $t += shift undef @x; @x empty'}; defined $t ? do{say 'B $t = shift undef @x; defined $t'} : do{say +'B $t = shift undef @x; undefined $t'}; print "\n"; say 'B: scalar context'; undef @y; @y ? do{say 'B undef @y; @y not empty'} : do{say 'B undef @y; @y e +mpty'}; my $v = splice( @y,0,1 ); @y ? do{say 'B $v = splice undef @y; @y not empty'} : do{say 'B $v + = splice undef @y; @y empty'}; defined $v ? do{say 'B $v = splice undef @y; defined $v'} : do{say + 'B $v = splice undef @y; undefined $v'}; print "\n"; exit; } say "A B Done\n"; exit; }else{ say "\n",'A B my @x @y Scalar Context',"\n"; }
C D my (@x),(@y) List Context
use strict; use warnings; use feature qw'say state'; use Data::Dump; use diagnostics -verbose; # C D my (@x),(@y) List Context my (@x); my (@y); if( ( fork() ) == 0 ){ if( ( fork() ) == 0 ){ say 'C: list context'; @x ? do{say 'C @x not empty'} : do{say 'C @x empty'}; my ($s) = shift @x; @x ? do{say 'C ($s) = shift @x; @x not empty'} : do{say 'C ($s) = +shift @x; @x empty'}; defined $s ? do{say 'C defined $s'} : do{say 'C undefined $s'}; print "\n"; say 'C: list context'; @y ? do{say 'C @y not empty'} : do{say 'C @y empty'}; my ($u) = splice( @y,0,1 ); @y ? do{say 'C ($u) = splice @y; @y not empty'} : do{say 'C ($u) = + splice @y; @y empty'}; defined $u ? do{say 'C ($u) = splice @y; defined $u'} : do{say 'C +($u) = splice @y; undefined $u'}; print "\n"; }else{ say 'D: list context'; undef @x; @x ? do{say 'D undef @x; @x not empty'} : do{say 'D undef @x; @x e +mpty'}; my ($t) = shift @x; @x ? do{say 'D ($t) = shift undef @x; @x not empty'} : do{say 'D ( +$t) = shift undef @x; @x empty'}; defined $t ? do{say 'D ($t) = shift undef @x; defined $t'} : do{sa +y 'D ($t) = shift undef @x; undefined $t'}; print "\n"; say 'D: list context'; undef @y; @y ? do{say 'D undef @y; @y not empty'} : do{say 'D undef @y; @y e +mpty'}; my ($v) = splice( @y,0,1 ); @y ? do{say 'D ($v) = splice undef @y; @y not empty'} : do{say 'D +($v) = splice undef @y; @y empty'}; defined $v ? do{say 'D ($v) = splice undef @y; defined $v'} : do{s +ay 'D ($v) = splice undef @y; undefined $v'}; print "\n"; exit; } say "C D Done\n"; exit; }else{ say "\n",'C D my (@x),(@y) List Context',"\n"; }
In reply to Re^3: shift on empty array in list context broken
by Don Coyote
in thread shift on empty array in list context broken
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |