On Mon, 2004-01-19 at 02:05, John W. Krahn wrote:
> Kenton Brede wrote:
> > 
> > I've been searching the archives and google for an answer.  I suspect it
> > can't be done but thought I'd ask.
> > 
> > What I'm trying to do is create a tool such as "cdargs", in perl, to
> > simplify moving between directories on the command line.
> > 
> > The problem I'm having of course is actually changing the shell's
> > working directory from the Perl script.  Is there anyway I can do this
> > with Perl?
> 
> It is very easy to change the directory from inside a Perl program
> however as soon as the program exits the changes will be lost.  This is
> true of Perl or C or Bash or anything that runs as a child of the
> shell. 

He's right, out of curiousity I tried the following:

% perl -e "`cd ..`;";
% ./test 
  # where test was:
  #! /bin/bash
  cd ..

And neither worked.  However, if he wanted to he could create a script
that moved to that directory, and ran a copy of sh or bash, couldn't
he?  Then pipe commands back and forth.

It would be terribly inefficient though.

-Dan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to