in reply to Re^5: shift on empty array in list context broken
in thread shift on empty array in list context broken
No, the context of x is not propagated.
the [...,...] is imposing list context
DB<50> x [ shift @x, splice @x,0,1 ] 0 ARRAY(0x34a5270) 0 undef
to enforce scalar context I used a scalar assignment
DB<60> x [ ($a=shift @x), ($b=splice @x,0,1) ]
if you have doubts enter a call to a sub which returns the context depending on wantarray
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: shift on empty array in list context broken (show context)
by LanX (Saint) on Jul 17, 2019 at 11:59 UTC | |
by Don Coyote (Hermit) on Jul 18, 2019 at 14:22 UTC | |
by Don Coyote (Hermit) on Jul 20, 2019 at 16:43 UTC | |
by LanX (Saint) on Jul 20, 2019 at 19:31 UTC | |
by Don Coyote (Hermit) on Jul 21, 2019 at 09:48 UTC | |
by LanX (Saint) on Jul 21, 2019 at 17:56 UTC | |
|