Cwd#
Native implementation of Cwd
Provides current working directory operations.
Synopsis#
use Cwd;
my $dir = cwd();
use Cwd 'abs_path';
my $abs = abs_path('relative/path');
my $abs = abs_path('/symlinked/../path');
Perl Equivalent#
Cwd
Functions#
cwd / getcwd / fastcwd / fastgetcwd#
Returns the current working directory as a string. All four names are synonyms in PetaPerl (no distinction between XS and pure-Perl implementations).
use Cwd;
my $dir = cwd();
abs_path / realpath / fast_abs_path#
Returns the canonicalized absolute pathname of the argument.
Resolves symlinks. Returns undef if the path cannot be resolved.
If no argument is given, resolves the current directory.
use Cwd 'abs_path';
my $abs = abs_path('relative/path');
my $abs = abs_path(); # current directory
chdir#
Changes the working directory and updates $ENV{PWD}.
Unlike CORE::chdir, does NOT default to $ENV{HOME} when
called without arguments. Returns 1 on success, 0 on failure.
use Cwd 'chdir';
chdir('/tmp') or die "Cannot chdir: $!";