other versions
- wheezy 5.14.2-21+deb7u3
- jessie 5.20.2-3+deb8u6
- testing 5.24.1-3
- unstable 5.24.1-3
- experimental 5.26.0-1
other sections
Cwd(3perl) | Perl Programmers Reference Guide | Cwd(3perl) |
NAME¶
Cwd - get pathname of current working directorySYNOPSIS¶
use Cwd; my $dir = getcwd; use Cwd 'abs_path'; my $abs_path = abs_path($file);
DESCRIPTION¶
This module provides functions for determining the pathname of the current working directory. It is recommended that getcwd (or another * cwd() function) be used in all code to ensure portability. By default, it exports the functions cwd(), getcwd(), fastcwd(), and fastgetcwd() (and, on Win32, getdcwd()) into the caller's namespace.getcwd and friends¶
Each of these functions are called without arguments and return the absolute path of the current working directory.- getcwd
-
my $cwd = getcwd();
- cwd
-
my $cwd = cwd();
- fastcwd
-
my $cwd = fastcwd();
- fastgetcwd
-
my $cwd = fastgetcwd();
- getdcwd
-
my $cwd = getdcwd(); my $cwd = getdcwd('C:');
abs_path and friends¶
These functions are exported only on request. They each take a single argument and return the absolute pathname for it. If no argument is given they'll use the current working directory.- abs_path
-
my $abs_path = abs_path($file);
- realpath
-
my $abs_path = realpath($file);
- fast_abs_path
-
my $abs_path = fast_abs_path($file);
$ENV{PWD}¶
If you ask to override your chdir() built-in function,use Cwd qw(chdir);then your PWD environment variable will be kept up to date. Note that it will only be kept up to date if all packages which use chdir import it from Cwd.
NOTES¶
- •
- Since the path separators are different on some operating systems ('/' on Unix, ':' on MacPerl, etc...) we recommend you use the File::Spec modules wherever portability is a concern.
- •
- Actually, on Mac OS, the "getcwd()", "fastgetcwd()" and "fastcwd()" functions are all aliases for the "cwd()" function, which, on Mac OS, calls `pwd`. Likewise, the "abs_path()" function is an alias for "fast_abs_path()".
AUTHOR¶
Originally by the perl5-porters. Maintained by Ken Williams <KWILLIAMS@cpan.org>COPYRIGHT¶
Copyright (c) 2004 by the Perl 5 Porters. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Portions of the C code in this library are copyright (c) 1994 by the Regents of the University of California. All rights reserved. The license on this code is compatible with the licensing of the rest of the distribution - please see the source code in Cwd.xs for the details.SEE ALSO¶
File::chdir2011-09-26 | perl v5.14.2 |