[sf-perl] IPC::Open3

David Alban extasia at extasia.org
Fri Sep 7 11:23:33 PDT 2007


Greetings,

I'm taking open3 for a test drive.  I thought that stderr would go to
the err handle.  But it seems it doesn't.

     1  #!/usr/bin/perl
     2
     3  use strict;
     4  use warnings;
     5
     6  use IPC::Open3;
     7
     8  my $pid = open3( my $wfh, my $rfh, my $efh, qw( ls -ld foo bar ) );
     9
    10  while ( <$rfh> ) {
    11    print "rfh: $_";
    12  } # while
    13
    14  while ( <$efh> ) {
    15    print "efh: $_";
    16  } # while

foo exists.  bar doesn't.  I'd expect the read file handle to contain
stdout, i.e., the listing for foo.  I'd expect the error file handle
to contain stderr, i.e., the message that bar doesn't exist.  But I
get both in the read handle:

    Use of uninitialized value in <HANDLE> at junk.perl line 14.
    readline() on unopened filehandle at junk.perl line 14.
    rfh: ls: cannot access bar: No such file or directory
    rfh: -rw-r--r-- 1 dalban Users 0 Sep  7 11:11 foo

What am I missing?

Thanks,
David
-- 
Live in a world of your own, but always welcome visitors.


More information about the SanFrancisco-pm mailing list