in reply to trouble with system commands

Hey
You can try the following...it works in my system
$cd=system("cd $directory");
Thanks & Regards
Sridhar

Replies are listed 'Best First'.
Re^2: trouble with system commands
by graff (Chancellor) on Nov 19, 2006 at 15:15 UTC
    Heh... usually we have to ask people: What do you mean when you say "it doesn't work"? But in your case, I have to ask: What do you mean when you say "it works"?
Re^2: trouble with system commands
by Joost (Canon) on Nov 19, 2006 at 14:51 UTC

      It should work on DOS.

        Actually, no, architecturally it shouldn't even work on MS-DOS from version 2.0 on. (Earlier 1.0 and 1.1 didn't implement subdirectories.) Of course, I don't know how far back we see any build of Perl for MS-DOS.

        Each system() call with spaces in it results in a new instance of COMMAND.COM (or in NT-speak, CMD.EXE). It is that interpreter which takes the single string and parses it into execution. Perl wouldn't pass the "cd foo" string to perl's parent interpreter, and there is no cd.exe, so this is how it has to happen. Anything under that instance of the command interpreter has one "active directory" for each lettered device. This is lost when the command shell quits.

        In Un*x, a process only sees the filesystem world as a single root, instead of several distinct lettered devices, and each process has its own current directory relative to that root.

        --
        [ e d @ h a l l e y . c c ]