diff --git a/op.c b/op.c index 7d5db41b58226..937d12ffa61b9 100644 --- a/op.c +++ b/op.c @@ -12416,6 +12416,8 @@ Perl_ck_eval(pTHX_ OP *o) PERL_ARGS_ASSERT_CK_EVAL; PL_hints |= HINT_BLOCK_SCOPE; + if(PL_prevailing_version != 0) + PL_hints |= HINT_LOCALIZE_HH; if (o->op_flags & OPf_KIDS) { SVOP * const kid = cSVOPx(cUNOPo->op_first); assert(kid); @@ -12457,6 +12459,7 @@ Perl_ck_eval(pTHX_ OP *o) && !(o->op_private & OPpEVAL_COPHH) && GvHV(PL_hintgv)) { /* Store a copy of %^H that pp_entereval can pick up. */ HV *hh = hv_copy_hints_hv(GvHV(PL_hintgv)); + hv_stores(hh, "CORE/prevailing_version", newSVuv(PL_prevailing_version)); OP *hhop; hhop = newSVOP(OP_HINTSEVAL, 0, MUTABLE_SV(hh)); /* append hhop to only child */ diff --git a/pp_ctl.c b/pp_ctl.c index 8c6c1a07723bc..2ad7175c41b8a 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -4062,6 +4062,7 @@ S_doeval_compile(pTHX_ U8 gimme, CV* outside, U32 seq, HV *hh) else { PL_hints = saveop->op_private & OPpEVAL_COPHH ? oldcurcop->cop_hints : (U32)saveop->op_targ; + PL_prevailing_version = 0; /* we might change this below */ /* making 'use re eval' not be in scope when compiling the * qr/mabye_has_runtime_code_block/ ensures that we don't get @@ -4076,6 +4077,12 @@ S_doeval_compile(pTHX_ U8 gimme, CV* outside, U32 seq, HV *hh) SvREFCNT_dec(GvHV(PL_hintgv)); GvHV(PL_hintgv) = hh; FETCHFEATUREBITSHH(hh); + SV *versv; + /* hh is a new copy for us to use; we are permitted to delete keys */ + if((versv = hv_deletes(hh, "CORE/prevailing_version", 0)) && SvOK(versv)) { + SAVEI16(PL_prevailing_version); + PL_prevailing_version = SvUV(versv); + } } } SAVECOMPILEWARNINGS();