This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
CopFILEGV(&PL_compiling) must be reset properly (from Doug MacEachern)
[perl5.git] / doio.c
diff --git a/doio.c b/doio.c
index d0a7704..3cd199b 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -646,13 +646,17 @@ Perl_nextargv(pTHX_ register GV *gv)
        else {
            dTHR;
            if (ckWARN_d(WARN_INPLACE)) {
-               if (!S_ISREG(PL_statbuf.st_mode))       
+               int eno = errno;
+               if (PerlLIO_stat(PL_oldname, &PL_statbuf) >= 0
+                   && !S_ISREG(PL_statbuf.st_mode))    
+               {
                    Perl_warner(aTHX_ WARN_INPLACE,
                                "Can't do inplace edit: %s is not a regular file",
                                PL_oldname);
+               }
                else
                    Perl_warner(aTHX_ WARN_INPLACE, "Can't open %s: %s",
-                               PL_oldname, Strerror(errno));
+                               PL_oldname, Strerror(eno));
            }
        }
     }