This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #123057] Allow split-to-array in lvalue context
authorFather Chrysostomos <sprout@cpan.org>
Mon, 27 Oct 2014 00:01:07 +0000 (17:01 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 27 Oct 2014 00:24:56 +0000 (17:24 -0700)
commite4e95921cd0fd085a5edf35ae358cd213529e55a
treecb723485b18f12ca5f0bb66c3a516a8d9ad68cf8
parent6c7f10b59397fa5a696d553f50ae0abc2bce312c
[perl #123057] Allow split-to-array in lvalue context

In some cases @a=split gets optimised to something akin to split(\@a,
...) or split(..., \@a), so lvalue context applied to it sees a split
op instead of a list assignment.  And split can’t be assigned to.  So (@a=split//,"foo")=bar() fails.  This bug probably goes back to perl
3, when this optimisation was added.

(Actually, the array is usually stowed away in the pushre op that
holds the regular expression, though sometimes it becomes the last
argument.)

Recent commits such as ef7999f have extended this optimisation, so
it happens in more places, and ended up breaking chomp(my @array =
split...).

This commits checks specifically for split-to-array when lvalue con-
text is applied.
op.c
t/op/chop.t
t/op/split.t