in reply to "- |" pipe option doesn't work

A self-pipe is not supported under Windows Perl. See perlport:

open to |- and -| are unsupported. (Win32, RISC OS)

Replies are listed 'Best First'.
Re^2: "- |" pipe option doesn't work
by BrowserUk (Patriarch) on Jan 09, 2017 at 16:29 UTC

    Hm. Is that doc quote 5.8.4 specific? Because it works okay in 5.8.9.

    This code:

    #! perl -slw use strict; open PIPE, '-|', q[ c:\\perl32\\bin\\perl.exe -v ] or die $^E; print "<<<$_>>>" while <PIPE>;

    Produces this output:

    C:\test>\perl32\bin\perl junk99.pl <<< >>> <<<This is perl, v5.8.9 built for MSWin32-x86-multi-thread >>> <<<(with 12 registered patches, see perl -V for more detail) >>> <<< >>> <<<Copyright 1987-2008, Larry Wall >>> <<< >>> <<<Binary build 826 [290470] provided by ActiveState http://www.Active +State.com >>> <<<Built May 24 2009 09:21:05 >>> <<< >>> <<<Perl may be copied only under the terms of either the Artistic Lice +nse or the >>> <<<GNU General Public License, which may be found in the Perl 5 source + kit. >>> <<< >>> <<<Complete documentation for Perl, including FAQ lists, should be fou +nd on >>> <<<this system using "man perl" or "perldoc perl". If you have access + to the >>> <<<Internet, point your browser at http://www.perl.org/, the Perl Home + Page. >>> <<< >>>

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
    In the absence of evidence, opinion is indistinguishable from prejudice.

      I think the quote specifically refers to the naked pipe-self-open:

      open my $fh, '-|' or die;

      which basically launches a forked copy of the current process. I don't think this has ever been implemented for Windows Perl.

        I think the quote specifically refers to the naked pipe-self-open:

        Ah. Okay, I never even knew *that* was a possibility. (Should have read the OP as well as your reply :)


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
        In the absence of evidence, opinion is indistinguishable from prejudice.
      I don't have a Win32 machine available now, but perlport in blead contains a slightly reformulated version of the same:
      open (Win32, RISC OS) Open modes "|-" and "-|" are unsupported.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re^2: "- |" pipe option doesn't work
by DavidLim (Initiate) on Jan 09, 2017 at 15:30 UTC
    Thanks for confirmation

      I don't see in your code why you would need a self-pipe+fork.

      For reading from an asynchronous process, I've used a plain pipe-open quite successfully:

      my $cmd = 'sdb shell hcidump |'; my $child = open( my $hci, $cmd ) or die "Couldn't spawn [$cmd]: $!"; while (<$hci>) { ... }; END { if( $child ) { kill 'KILL' => $child; }; $child = 0; };

      Update: There was the pipe missing from the command line, whoops!