1 # By Brandon S. Allbery
3 # This library is no longer being maintained, and is included for backward
4 # compatibility with Perl 4 programs which may require it.
5 # This legacy library is deprecated and will be removed in a future
7 # In particular, this should not be used as an example of modern Perl
8 # programming techniques.
10 # Suggested alternative: Cwd
12 warn( "The 'getcwd.pl' legacy library is deprecated and will be"
13 . " removed in the next major release of perl. Please use the"
14 . " Cwd module instead." );
17 # Usage: $cwd = &getcwd;
21 local($dotdots, $cwd, @pst, @cst, $dir, @tst);
23 unless (@cst = stat('.'))
31 $dotdots .= '/' if $dotdots;
34 unless (opendir(getcwd'PARENT, $dotdots)) #'))
36 warn "opendir($dotdots): $!";
39 unless (@cst = stat($dotdots))
41 warn "stat($dotdots): $!";
42 closedir(getcwd'PARENT); #');
45 if ($pst[$[] == $cst[$[] && $pst[$[ + 1] == $cst[$[ + 1])
53 unless (defined ($dir = readdir(getcwd'PARENT))) #'))
55 warn "readdir($dotdots): $!";
56 closedir(getcwd'PARENT); #');
59 unless (@tst = lstat("$dotdots/$dir"))
61 # warn "lstat($dotdots/$dir): $!";
62 # closedir(getcwd'PARENT); #');
66 while ($dir eq '.' || $dir eq '..' || $tst[$[] != $pst[$[] ||
67 $tst[$[ + 1] != $pst[$[ + 1]);
70 closedir(getcwd'PARENT); #');