##
use File::pushd;
{
my $wd = pushd();
chdir('subdir');
# do some work.
}
# automatically back in original dir
####
use File::pushd;
{
my $wd = tempd();
# do work in the temporary directory
}
# back in the original directory and the temporary directory is deleted