pipe-open on win32

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I'm having some trouble doing a pipe-open on Win32.
I suppose I was under the impression that perl
performed some magic when it encounters the '-|',
but it appears to simply pass the string to the

use strict;
use warnings;

print "Starting...\n";
unless (open (F, '-|')) {
    open STDERR, ">&=1";
    exec qw/ping localhost/;
    die $!;
my $buf = "";
while (<F>) {
    $buf .= $_;
    print "Buffer:\n $buf\n";
print "Done!\n";
'-' is not recognized as an internal or external command,
operable program or batch file.

I'm using Activestate 5.8.4. perlipc didn't suggest platform
specific quirks (unless I missed something) and nor did
the "Windows specific quirks" documentation in my version of
Perl mention pipe opens.

Is it possible to successfully do this type of open on


Re: pipe-open on win32

bdm wrote:
Quoted text here. Click to load it

There's a reference in perlport (Interprocess Communication section) to
using open() in this manner. You can use pipe():

use strict;
use warnings;
pipe my $reader, my $writer or die $!;
if ( my $pid = fork ) {
   close $writer or die $!;
   print while <$reader>;
   # waitpid($pid, 0);
} else {
   close $reader or die $!;
   exec qw/ping localhost/ or die $!;

HTH - keith

Site Timeline