shridhar22 has asked for the wisdom of the Perl Monks concerning the following question:
I have a list of paths in a file => small.txt i wish to open that file, copy the path and change my directory to the path collected from small.txt.
use Cwd; $BACK= getcwd(); open(LIST,"small.txt") or die "Cant open small.txt"; @arr= <LIST>; for($i = 0; $i < @arr; $i++) { chomp($arr[$i]); print "path read from file = $arr[$i]\n"; #it displays => ms_qu/the/path/written/in/file (fine till here but +it shud go to this place when i use chdir) chdir $arr[$i] or die "$1"; print "After chdir, cwd is = "; system("pwd"); chdir($BACK); print "Now im back to where i started"; system("pwd"); }
Now im not able to change my directory to the path in $arr$i. it shows me the die msg and doesnt change pwd. format of path in small.txt: xyx/abs/def/ijk Although if i write chdir(/abc/def/ijk), it works fine but i want chdir($variable) where value of variable is collected from small.txt PLEASE PLEASE PLEASE HELP ME!!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using chdir($variable_name) to change directory
by Tux (Canon) on Jul 05, 2011 at 11:36 UTC | |
|
Re: using chdir($variable_name) to change directory
by roboticus (Chancellor) on Jul 05, 2011 at 11:32 UTC | |
by shridhar22 (Novice) on Jul 06, 2011 at 07:23 UTC | |
by roboticus (Chancellor) on Jul 06, 2011 at 11:09 UTC | |
by Anonymous Monk on Jul 06, 2011 at 12:12 UTC | |
by shridhar22 (Novice) on Jul 07, 2011 at 04:54 UTC | |
by shridhar22 (Novice) on Jul 07, 2011 at 04:56 UTC | |
|
Re: using chdir($variable_name) to change directory
by Anonymous Monk on Jul 05, 2011 at 11:32 UTC |