in reply to Perl on cygwin

ysth is correct, using cd will only change the child process, regardless of Cygwin. However, on the assumption that you are using another command which follows (you don't actually say what you are trying to do) then the following works on Cygwin:
system('sh -c "cd ..;ls"');

This invokes the Bourne shell to execute its built-in cd command.

update: 'which cd' gives a similar message on bash and ksh on Linux ('no cd in ...') because cd is a shell built-in. Try 'type cd' instead'

If all you want to do is cat(1) there are very easy ways of doing that in Perl without invoking another program.

Replies are listed 'Best First'.
Re^2: Perl on cygwin (sh -c)
by tye (Sage) on Nov 19, 2007 at 16:30 UTC
    system('sh -c "cd ..;ls"');

    That is better written as:

    system('cd ..;ls');

    - tye        

      Yes, it does save one process besides being shorter. Still it could give wrong results if cd fails. A true shell hacker ;) would write system('cd ... && ls') (would even use 'ls -1' to avoid terminal issues).

      cheers --stephan