perl: chdir in perl and call chdir from system

384 Views Asked by At

In my perl script, use chdir command from Perl iteself works well as following:
chdir $fold_path

but use qx call chdir command of linux doesn't work as following:

qx(chdir $fold_path)

so what is the reason? Not so clear!

1

There are 1 best solutions below

2
On

There are two reasons:

  1. There's no chdir in Linux. It's called cd.

  2. After you change directory in qx, it only affects the child process. It doesn't change the working directory for the parent, i.e. the Perl script that called it.