File::pushd

File::pushd is a Perl module to change directory temporarily for a limited scope.
Download

File::pushd Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • David A Golden
  • Publisher web site:
  • http://search.cpan.org/~dagolden/Statistics-RankOrder-0.12/lib/Statistics/RankOrder.pm

File::pushd Tags


File::pushd Description

File::pushd is a Perl module to change directory temporarily for a limited scope. File::pushd is a Perl module to change directory temporarily for a limited scope.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} # tempd() is equivalent to pushd( File::Temp::tempdir ) { my $dir = tempd(); } # object stringifies naturally as an absolute path { my $dir = pushd( '/tmp' ); my $filename = File::Spec->catfile( $dir, "somefile.txt" ); # gives /tmp/somefile.txt }File::pushd does a temporary chdir that is easily and automatically reverted, similar to pushd in some Unix command shells. It works by creating an object that caches the original working directory. When the object is destroyed, the destructor calls chdir to revert to the original working directory. By storing the object in a lexical variable with a limited scope, this happens automatically at the end of the scope.This is very handy when working with temporary directories for tasks like testing; a function is provided to streamline getting a temporary directory from File::Temp.For convenience, the object stringifies as the canonical form of the absolute pathname of the directory entered. Requirements: · Perl


File::pushd Related Software