On Jan 29, 2008 8:34 AM, David Golden <[EMAIL PROTECTED]> wrote: > On Jan 29, 2008 3:44 AM, Michael G Schwern <[EMAIL PROTECTED]> wrote: > > Module::Build. I prefer the descriptive local_chdir() over the very Unixy > > and > > cryptic pushd().
I've been thinking about adding a feature to Path::Class that lets you perform an action in a certain directory, and be guaranteed of being back where you started afterwards. Hopefully could use fchdir() to be bulletproof. The possible interfaces include: $dir->do_something( \&what_to_do ); or the DESTROY trick like yours: { my $sentinel = $dir->scoped_chdir(); ...do your stuff... } The ideal situation would be if we could hook into perl's actual scoping mechanisms and eliminate the sentinel: { $dir->local_chdir(); ...do your stuff... } but that's probably out of my ken. -Ken