http://www.perlmonks.org?node_id=91719

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to do what I mean:
if ($foo) { local $cwd = ".."; /* current working directory changes */ ... } /* cwd is back to original directory */


The semantics being:
if ($foo) { my $old_cwd = cwd; chdir ".."; ... chdir $old_cwd; }