summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-09-25 20:34:11 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-10-10 21:56:48 -0700
commit6102323a2ca31b7c760d9a3b81cb1d3e3d551206 (patch)
tree996fef86c65479c81a0fe7f50dc70f0ebd92978a /pp.c
parent2a57afb16e3315d9a0aaa4e79615282cf63c970d (diff)
downloadperl-6102323a2ca31b7c760d9a3b81cb1d3e3d551206.tar.gz
Assignment to array elem refs
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/pp.c b/pp.c
index 931734fe65..ebb2a33cfb 100644
--- a/pp.c
+++ b/pp.c
@@ -6163,6 +6163,7 @@ PP(pp_runcv)
PP(pp_refassign)
{
dSP;
+ SV * const key = PL_op->op_private & OPpLVREF_ELEM ? POPs : NULL;
SV * const left = PL_op->op_flags & OPf_STACKED ? POPs : NULL;
dTOPss;
if (!SvROK(sv)) DIE(aTHX_ "Assigned value is not a reference");
@@ -6187,6 +6188,10 @@ PP(pp_refassign)
}
gv_setref(left, sv);
SvSETMAGIC(left);
+ break;
+ case SVt_PVAV:
+ av_store((AV *)left, SvIV(key), SvREFCNT_inc_simple_NN(SvRV(sv)));
+ break;
}
if (PL_op->op_flags & OPf_MOD)
SETs(sv_2mortal(newSVsv(sv)));
@@ -6199,9 +6204,10 @@ PP(pp_lvref)
{
dSP;
SV * const ret = sv_2mortal(newSV_type(SVt_PVMG));
+ SV * const elem = PL_op->op_private & OPpLVREF_ELEM ? POPs : NULL;
SV * const arg = PL_op->op_flags & OPf_STACKED ? POPs : NULL;
sv_magic(ret, arg,
- PERL_MAGIC_lvref, NULL, ARGTARG);
+ PERL_MAGIC_lvref, (char *)elem, elem ? HEf_SVKEY : ARGTARG);
if (PL_op->op_private & OPpLVAL_INTRO)
if (PL_op->op_flags & OPf_STACKED) {
save_pushptrptr((GV *)arg, SvREFCNT_inc_simple(GvSV(arg)),