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).


In reply to Re: 'C:\Program' is not recognized as an internal or external command, operable program or batch file. by aitap
in thread 'C:\Program' is not recognized as an internal or external command, operable program or batch file. by prab2112

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.