perl 5.003_06: pod/perlcall.pod pod/perldata.pod pod/perldebug.pod pod/perlembed...
[p5sagit/p5-mst-13.2.git] / lib / getcwd.pl
index 114e890..d886018 100644 (file)
@@ -36,15 +36,15 @@ sub getcwd
        {
            do
            {
-               unless ($dir = readdir(getcwd'PARENT))                  #'))
+               unless (defined ($dir = readdir(getcwd'PARENT)))        #'))
                {
                    warn "readdir($dotdots): $!";
                    closedir(getcwd'PARENT);                            #');
                    return '';
                }
-               unless (@tst = stat("$dotdots/$dir"))
+               unless (@tst = lstat("$dotdots/$dir"))
                {
-                   warn "stat($dotdots/$dir): $!";
+                   warn "lstat($dotdots/$dir): $!";
                    closedir(getcwd'PARENT);                            #');
                    return '';
                }
@@ -54,7 +54,7 @@ sub getcwd
        }
        $cwd = "$dir/$cwd";
        closedir(getcwd'PARENT);                                        #');
-    } while ($dir);
+    } while ($dir ne '');
     chop($cwd);
     $cwd;
 }