in reply to Re^2: using chdir($variable_name) to change directory
in thread using chdir($variable_name) to change directory

Dear shridhar22, you need to read and understand Re: using chdir($variable_name) to change directory

Relative paths are relative

If you're standing in the living room, and ask me for directions to the bathroom and the bedroom, and I tell you:
the bathroom is first door on the left
the bedroom is second door on the right

And you visit the bathroom successfully, and now wish to go to the bedroom, you can't go to the second door on the right!!

The bedroom, is the second door on the right, only if your starting position is the living room.

If your starting position is the bathroom, the second door on the right is not the bedroom!

To find the bedroom by the path "the second door on the right" you have to go back to the living room.

  • Comment on Re^3: using chdir($variable_name) to change directory

Replies are listed 'Best First'.
Re^4: using chdir($variable_name) to change directory
by shridhar22 (Novice) on Jul 07, 2011 at 04:54 UTC

    Dear Tux, i understand what u r trying to explain. im definetely comming back to where i started. sorry i didnt include the full code...which includes coming back to cwd but it still doesnt work.

    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"); }
Re^4: using chdir($variable_name) to change directory
by shridhar22 (Novice) on Jul 07, 2011 at 04:56 UTC
    and thanks for such a nice explanation sir!!