Help for this page

Select Code to Download


  1. or download this
    use strict; 
    use warnings;
    ...
    
    # Get back to the starting point
    chdir $initial_dir;
    
  2. or download this
    ok 1 - changed to new directory
    ok 2 - changed back to original directory
    1..2
    
  3. or download this
    not ok 1 - changed to new directory
    #     Failed test (cwd_post1.pl at line 26)
    ...
    ok 2 - changed back to original directory
    1..2
    # Looks like you failed 1 test of 2.
    
  4. or download this
    -    is( cwd(), $new_dir, "changed to new directory" );
    +    is( File::Spec->canonpath( cwd() ), $new_dir, "changed to new dir
    +ectory" );
    
  5. or download this
    -    my $new_dir = pushd( 't' );
    +    my $new_dir = pushd( File::Spec->rootdir );
    
  6. or download this
    not ok 1 - changed to new directory
    #     Failed test (cwd_post3.pl at line 26)
    ...
    ok 2 - changed back to original directory
    1..2
    # Looks like you failed 1 test of 2.
    
  7. or download this
    -    is( File::Spec->canonpath( cwd() ), $new_dir, "changed to new dir
    +ectory" );
    +    is( File::Spec->abs2rel( cwd(), $new_dir), File::Spec->curdir, 
    +        "changed to new directory" 
    +    );
    
  8. or download this
    not ok 1 - changed to new directory
    #     Failed test (cwd_post4.pl at line 26)
    #          got: ''
    #     expected: '.'
    ok 2 - changed back to original directory
    
  9. or download this
    $ perl -MFile::Spec -e 'print File::Spec->catdir(".","t")'
    t
    
    $ perl -MFile::Spec -e 'print File::Spec->catdir("","t")'
    /t
    
  10. or download this
    not ok 1 - changed to new directory
    #     Failed test (cwd_post4.pl at line 26)
    ...
    ok 2 - changed back to original directory
    1..2
    # Looks like you failed 1 test of 2.
    
  11. or download this
     use File::Spec;
    +use File::Spec::Functions qw( canonpath splitpath );
    
  12. or download this
    -    is( File::Spec->abs2rel( cwd(), $new_dir), q{.}, 
    +    is( canonpath( [ splitpath( cwd(), 1 ) ]->[1] ), 
    +        $new_dir, 
             "changed to new directory" 
         );
    
  13. or download this
    -    my $new_dir = pushd( File::Spec->rootdir );
    +    my $new_dir = pushd( "t" );
    
  14. or download this
    -    is( canonpath( [ splitpath( cwd(), 1 ) ]->[1] ), 
    -        $new_dir, 
    ...
    +        canonpath( [ splitpath( $new_dir, 1 ) ]->[1] ), 
             "changed to new directory" 
         );
    
  15. or download this
    -use Cwd;
    +use Cwd qw( cwd abs_path );
     use File::Spec;
    -use File::Spec::Functions qw( canonpath splitpath );
    
  16. or download this
    -    is( canonpath( [ splitpath( cwd(),    1 ) ]->[1] ), 
    -        canonpath( [ splitpath( $new_dir, 1 ) ]->[1] ), 
    -        "changed to new directory" 
    -    );
    +    is( cwd(), abs_path( $new_dir ), "changed to new directory" );
    
  17. or download this
    -    my $new_dir = pushd( "t" );
    +    my $new_dir = pushd( File::Spec->rootdir );