perl programming help?

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.

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
chdir $arr[$i] or die "$1";
print "After chdir, cwd is = ";
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!!!



@martin : thanks for the reply, but i even tried editing the format in small.txt , i tried all of the formats written below but none works:!!

/the/path/in/file
the/path/in/file
./the/path/in/file
"the/path/in/file"

but problem persists
 
If you read carefully, you answered your own question. Notice that when you say it works fine, there is a slash at the front of the path (an absolute path). Notice that when you say it fails, there is NO slash in front (a relative path). You should have die $!, not $1, in order to see the actual error message.
 
Back
Top