Acme-CPANModules-TemporaryChdir

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN


my %FallbackPrereqs = (
  "File::Spec" => 0,
  "IO::Handle" => 0,
  "IPC::Open3" => 0,
  "Test::More" => 0,
  "strict" => 0
);


unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
  delete $WriteMakefileArgs{TEST_REQUIRES};
  delete $WriteMakefileArgs{BUILD_REQUIRES};
  $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}

delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
  unless eval { ExtUtils::MakeMaker->VERSION(6.52) };

WriteMakefile(%WriteMakefileArgs);

README  view on Meta::CPAN

    Changing directory can be tricky if you are doing it in a transaction or
    inside a routine where you need to restore the previous working
    directory whether your main action succeeds or not. Forgetting doing it
    and it will cause unexpected behavior for the user calling your code.

    Restoring previous directory can be as simple as:

     use Cwd qw(getcwd);
 
     my $prevcwd = getcwd();
     eval {
         # do some stuffs that might die ...
     };
     # check success status ...
     chdir $prevcwd or die "Can't chdir back to '$prevcwd': $!";

    but it can get tedious. Some modules can help. These modules employ one
    of several mechanisms provided by Perl:

    1) Tied scalar, where reading from the scalar retrieves the current
    working directory and writing to it changes the working directory. The

lib/Acme/CPANModules/TemporaryChdir.pm  view on Meta::CPAN

Changing directory can be tricky if you are doing it in a transaction or inside
a routine where you need to restore the previous working directory whether your
main action succeeds or not. Forgetting doing it and it will cause unexpected
behavior for the user calling your code.

Restoring previous directory can be as simple as:

    use Cwd qw(getcwd);

    my $prevcwd = getcwd();
    eval {
        # do some stuffs that might die ...
    };
    # check success status ...
    chdir $prevcwd or die "Can't chdir back to '$prevcwd': $!";

but it can get tedious. Some modules can help. These modules employ one of
several mechanisms provided by Perl:

1) Tied scalar, where reading from the scalar retrieves the current working
directory and writing to it changes the working directory. The user can set the

lib/Acme/CPANModules/TemporaryChdir.pm  view on Meta::CPAN

Changing directory can be tricky if you are doing it in a transaction or inside
a routine where you need to restore the previous working directory whether your
main action succeeds or not. Forgetting doing it and it will cause unexpected
behavior for the user calling your code.

Restoring previous directory can be as simple as:

 use Cwd qw(getcwd);
 
 my $prevcwd = getcwd();
 eval {
     # do some stuffs that might die ...
 };
 # check success status ...
 chdir $prevcwd or die "Can't chdir back to '$prevcwd': $!";

but it can get tedious. Some modules can help. These modules employ one of
several mechanisms provided by Perl:

1) Tied scalar, where reading from the scalar retrieves the current working
directory and writing to it changes the working directory. The user can set the

t/00-compile.t  view on Meta::CPAN

            $^X, @switches, '-e', "require q[$lib]"))
        if $ENV{PERL_COMPILE_TEST_DEBUG};

    my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
    binmode $stderr, ':crlf' if $^O eq 'MSWin32';
    my @_warnings = <$stderr>;
    waitpid($pid, 0);
    is($?, 0, "$lib loaded ok");

    shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
        and not eval { +require blib; blib->VERSION('1.01') };

    if (@_warnings)
    {
        warn @_warnings;
        push @warnings, @_warnings;
    }
}





( run in 0.818 second using v1.01-cache-2.11-cpan-ceb78f64989 )