http://qs321.pair.com?node_id=1107636


in reply to 'C:\Program' is not recognized as an internal or external command, operable program or batch file.

Wherever available, you should use LIST-style forms of command launching functions. For example, prefer system("rm", "-rf", @temp_directories) over system("rm -rf @unneeded"). The same goes for pipe-open, exec and so on.

This is because when Perl encounters a command which consists of a single string containing so called special characters it passes the whole string to the shell. And modern filesystems allow spaces in file names which are not getting escaped, and this is where your command breaks. Some filesystems even allow glob characters (like * [ ]). Even more fun: imagine creating a file called -rf ~ and trying to remove it by system("rm $filename").

Bad news: list form of open is not supported on Windows. Good news: list form of open2 is. And so is high-level IPC::Run (but I got some problems with binary files transferred via pipe when I used this module).

  • Comment on Re: 'C:\Program' is not recognized as an internal or external command, operable program or batch file.
  • Select or Download Code