chdir `perl -e 'print quotemeta("/some/path")'` #### $ cat script.pl print("set var=val\n"); print("set foo=bar\n"); print("cd /some/path\n"); $ script.pl > temp_file && source temp_file && rm temp_file #### >type script.pl print("set var=val\n"); print("set foo=bar\n"); print("cd \\some\\path\n"); >for /f "usebackq delims=" %%f in (`script.pl`) do %%f