use Cwd; my $dir = cwd(); chdir $otherdir; # do something chdir $dir;