I recently ran into the same problem and found this node. Before giving up I investigated further and decided that the standard answer (that this has to do with problems of wperl with STDERR) is incorrect or at least outdated. The problem is actually caused by open3 trying to set up a handle for STDIN. If you follow the code it turns out that in the end it does open(IN, "<&GLOB") where GLOB is a glob copy of STDIN. This fails under wperl (probably because STDIN is not sufficiently set up, I didn't trace that further). With that in mind I tried to set up a fake STDIN before doing the call and that seems to work as a workaround:
#!/usr/bin/perl -w use strict; use IPC::Open3; open(STDIN, "<", "NUL") || die "open NUL: $!"; local (*IN,*OUT,*ERR); my $pid = open3(\*IN, \*OUT, \*ERR, "wperl", q(-le), q(my $in = <STDIN +>; print $in+3; print STDERR $in+5)); print IN "5\n"; close IN; my $line = <OUT>; print "Out=$line"; $line = <ERR>; print "Err=$line";
And then:
wperl program > out 2>&1 type out
gives
Out=8 Err=10
Setting a global STDIN in the outer wperl is no great loss since it is not typically connected to anything anyways. If you want to be able to maybe use the STDIN of the outer wperl in case it is available I suppose you can replace the initial open by something like
{ open(my $dummy, "<&STDIN") || open(STDIN, "<", "NUL") || die "open + NUL: $!"; }

In reply to Re: IPC::Open3, wperl issue by thospel
in thread IPC::Open3, wperl issue by nusoff

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.