From the "Caveats and limitations" section of perlipc (AS 5.8 html).

Forking pipe open() not yet implemented

The open(FOO, "|-") and open(BAR, "-|") constructs are not yet implemented. This limitation can be easily worked around in new code by creating a pipe explicitly. The following example shows how to write to a forked child: ...

The error message you are seeing is because '-' is being passed to CMD as a command, and it isn't:).

It would be nice if this unimplemented feature of perl actually issued a "Unimplemented feature" warning wouldn't it.

However, the above quote goes on to show a reasonably simply way of emulating the feature under Win32. Makes me wonder why, if it's so easy to emulate, why it isn't done for us, but there's probably a good reason.

Update: The appears to be a bug in the sample code given for the pipe_from_fork() emulation. Using AS 5.8, it didn't work for me until I added close STDOUT; just before the open( STDOUT, ">&="... in the else clause.

Anyone know if there is an easy method of reporting such documentation bugs? Should this go to AS or P5P?

One additional caveat. Remember that unlike 'ls' on *nix, 'dir' is not an executable but a builtin-in command of the shell, so it's not a good candidate for testing with. You need some other command that is an executable that produces output to stdout for this purpose.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.


In reply to Re: Capturing output from Child processes by BrowserUk
in thread Capturing output from Child processes by Biff

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.