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!!!
In reply to using chdir($variable_name) to change directory by shridhar22
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |