in reply to Re: Re: shell cd within perl script
in thread shell cd within perl script

A shell script can't do it either, for much the same reason. In most shells you can use a shell function to affect the current shell's environment. If your Perl script needs to determine what directory to go to, you can just have it print that out, then use cd `your_script` in the shell function to actually change to that directory.

For example, here's a Bash shell function using a perl script:

function test() { cd `perl -e 'print "/tmp\n";'`; }

Replies are listed 'Best First'.
Re: Re: Re: Re: shell cd within perl script
by qq (Hermit) on Apr 20, 2004 at 11:44 UTC

    This is essentially the solution I've adopted. My perl script just creates shortcuts through a complicated directory structure. I'm running it like: cd `script.pl arg`

    qq