This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make encoding pragma lexical in scope
[perl5.git] / gv.c
diff --git a/gv.c b/gv.c
index eaf9d21..4f072d7 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -1846,7 +1846,7 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len,
        } else
 #endif
        {
-           const char * const name2 = name + 1;
+           const char * name2 = name + 1;
            switch (*name) {
            case 'A':
                if (strEQ(name2, "RGV")) {
@@ -1905,6 +1905,9 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len,
                    goto magicalize;
                break;
            case '\005':        /* $^ENCODING */
+                if (*name2 == '_') {
+                    name2++;
+                }
                if (strEQ(name2, "NCODING"))
                    goto magicalize;
                break;