[patch perlguts.pod] save_item doesn't handle magic
[p5sagit/p5-mst-13.2.git] / pp_ctl.c
index 42d63c6..c5f802a 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -954,8 +954,15 @@ PP(pp_mapwhile)
        (void)POPMARK;                          /* pop dst */
        SP = PL_stack_base + POPMARK;           /* pop original mark */
        if (gimme == G_SCALAR) {
-           dTARGET;
-           XPUSHi(items);
+           if (PL_op->op_private & OPpGREP_LEX) {
+               SV* sv = sv_newmortal();
+               sv_setiv(sv, items);
+               PUSHs(sv);
+           }
+           else {
+               dTARGET;
+               XPUSHi(items);
+           }
        }
        else if (gimme == G_ARRAY)
            SP += items;