in reply to perl and unc paths

\\ in string literals only adds \ to the string being built. In other words, you need to double up \ chars (and add a \ in front of ' chars) in your string literal:
system('pushd \\\\comp1\\newfolder');

But that's not going to do what you want. system will create a new shell for pushd to run in, and pushd will only affect that shell. (It will also affect any child that shall will later spawn, but it spawns none as is.)

Use chdir to change the working directory of the Perl script (and any children it later spawns). The current directory will get automatically restored when the script ends. If that's too late, use Cwd to find out which directory is the current working directory, and use chdir to restore it when you wish to do so.

Replies are listed 'Best First'.
Re^2: perl and unc paths
by Anonymous Monk on Aug 22, 2016 at 18:29 UTC
    Except 'chdir \\\\comp1\\newfolder doesnt work!'

        Like pushd does, you'll need to create a virtual drive first

      On Windows that is... pushd and popd would work, except you can't do system("pushd \\\\unc_path1\\folder") because it spawns a new shell and then exits with system()