Consider looking at perlop to see what -x does. Also, if it "always fails" (and you're interested in learning why), consider posting full code.

Please note that dir and date are shell builtins in cmd.exe and thus never pass -x, because they are not programs that can be run. Also note that -x expects the full path to an executable and does not search $ENV{PATH}. Whether that is desired or not in the context of the above program, I don't know. Update: As the argument is passed to Win32::Process::Create(...), it makes sense to have a fully specified path, because that's what Win32::Process::Create() likely wants.

>perl -wle "print $_, -x $_ ? ' yes':' no' for @ARGV" cmd.exe c:\WINDO +WS\system32\cmd.exe cmd.exe no c:\WINDOWS\system32\cmd.exe yes

As to using system or backticks, these do not launch a background process. Which seems to be the purpose of the code under discussion. Actually, perlport points out system(1, ...) for launching a process in the background under Windows and OS/2.


In reply to Re^5: Perl Background processes in Windows by Corion
in thread Perl Background processes in Windows by spx2

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.