Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

question about chdir

Status
Not open for further replies.

donny750

Programmer
Jul 13, 2006
145
FR
hello,

In my script, i use chdir to change directory and run a function;
I explain with an example :
I run my script from /home/tom/axa
In my script i do : chdir ("/home/test");
after my chdir ,the script do another thing but where i am ?
in /home/tom/axa or in /home/test ?

Thanks

 
Code:
use Data::Dumper;
.
.
.
.
chdir(blah);

print Dumper(%ENV);
Should have an entry for the current directory in it somewhere...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
i make this

Code:
my $x = qx(pwd);
..
# now $x contain /home/tom/axa
chdir ("/home/test");
..
chdir ($x);
 
>> In my script i do : chdir ("/home/test");

you're in "home/test" unless you chdir back or chdir to another directory.


use the cwd module to find which is the current working diretory:


the documentation is very clear on how to use it.

- Kevin, perl coder unexceptional!
 
thanks i use
my $cwd = cwd();
it's like pwd but in perl.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top