This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[win32] merge changes#982,984 from maintbranch
[perl5.git] / gv.c
diff --git a/gv.c b/gv.c
index 94d4a7e..b48e4d8 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -709,13 +709,28 @@ gv_fetchpv(char *nambeg, I32 add, I32 sv_type)
 #endif
        goto magicalize;
 
+    case '!':
+       if(len > 1)
+           break;
+       if(sv_type > SVt_PV) {
+           HV* stash = gv_stashpvn("Errno",5,FALSE);
+           if(!stash || !(gv_fetchmethod(stash, "TIEHASH"))) {
+               dSP;
+               PUTBACK;
+               perl_require_pv("Errno.pm");
+               SPAGAIN;
+               stash = gv_stashpvn("Errno",5,FALSE);
+               if (!stash || !(gv_fetchmethod(stash, "TIEHASH")))
+                   croak("Can't use %%! because Errno.pm is not avaliable");
+           }
+       }
+       goto magicalize;
     case '#':
     case '*':
        if (dowarn && len == 1 && sv_type == SVt_PV)
            warn("Use of $%s is deprecated", name);
        /* FALL THROUGH */
     case '[':
-    case '!':
     case '^':
     case '~':
     case '=':