in reply to using chdir($variable_name) to change directory
Do you return to the previous path before chdir? If not, relative PATH's will fail
use strict; use warnings; use autodie; use Cwd; my $base = getcwd; open my $lh, "<", "small.txt"; chomp (my @arr= <$lh>); # remove newlines close $lh; foreach my $dir (@arr) { # don't use C-like for when you don't use the + index var chdir $base; # always return to base before the next chdir print "path read from file = $path\n"; # it displays => ms_qu/the/path/written/in/file # Which is a *relative* path name chdir $dir or die "$1"; # WTF is $1? print "After chdir, cwd is = ", getcwd, "\n"; }
|
|---|