http://qs321.pair.com?node_id=488620

I just released File::pushd 0.20 to CPAN. It provides for a temporary directory change that reverts at the end of a scope (similar to File::chdir but works on Win32). From the synopsis:

use File::pushd; chdir $ENV{HOME}; # change directory again for a limited scope { my $dir = pushd( '/tmp' ); # working directory changed to /tmp } # working directory has reverted to $ENV{HOME} # equivalent to pushd( File::Temp::tempdir ) { my $dir = tempd(); }

I wrote this as a helper module for my test scripts and it seeemed like it might be useful to others. Comments and critique welcome.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.