in reply to How to change path

This snippet
$pwd=`pwd`; print "\n pwd is $pwd"; `cd /usr/bin`; $pwd=`pwd`; print "\n pwd is $pwd\n";
is not changing the dir "/usr/bin" , I reason I suppose is if we execute a command directly using back-ticks(`) it will execute in a new shell.But system() will execute the commands in same shell.Am I right??

The world is so big for any individual to conquer

Replies are listed 'Best First'.
Re^2: How to change path
by snowhare (Friar) on Oct 25, 2007 at 11:16 UTC
    No. You're not right. 'system' forks a *new* process to execute the requested command. 'exec' would execute the command in the same process, but that would have the effect of _ending_ the Perl program to launch the new one (IOW, the program would never 'return' to the Perl program because it would _replace_ it). As someone else said, to do what the OP appears to want to do, they should use the Perl function 'chdir'.