This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
&CORE::substr()
This commit makes &CORE::substr callable through references and via
&ersand syntax.
It’s a bit awkward, as we need a substr op that is flagged as hav-
ing 4 arguments *and* possibly returning an lvalue. The code in
op_lvalue_flags wasn’t really set up for that, so I needed to flag
the op with OPpMAYBE_LVSUB in coresub_op before it gets passed to
op_lvalue_flags. It turned out that only that was necessary, as
op_lvalue_flags does an op_private == 4 check (rather than (op_private
& 7) == 4 or some such) when checking for the 4-arg case and croak-
ing. When the op arrives in op_lvalue_flags, it’s already flagged
OPpMAYBE_LVSUB|4 which != 4.
pp_substr is also modified to check for nulls and, if necessary,
adjust its count of how many arguments were actually passed.)