my $path = "/dir1/dir2/dir3/ .. /dirn-1/dirLast//"; my @pathary = split(/\//,$path); my $parentpath = join('/',@pathary[0..$#pathary-1]); # pop @path; # also # my $parentpath = join('/',@pathary); # works print "$path\n$parentpath\n"; #### use Cwd; my $oldpath = getcwd(); print "$oldpath\n"; $path = '/var/tmpdir'; chdir $path; $path = getcwd(); # for info only print "$path\n"; # for info only chdir "../"; $path = getcwd(); print "$path\n";