P
Peter Makholm
I'm trying to use IPC::Open3 but have some problem with the error
filehandle not being used. Try the following script:
#!/usr/bin/perl
use IPC::Open3;
use Data:umper;
my ( $in, $out, $err );
open3($in,$out,$err, "/usr/bin/sort");
print Dumper [$in, $out, $err];
__END__
I would expect output like:
$VAR1 = [
\*Symbol::GEN0,
\*Symbol::GEN1,
\*Symbol::GEN2,
];
but I get output like
$VAR1 = [
\*Symbol::GEN0,
\*Symbol::GEN1,
undef
];
Reading the documentation, it clearly states that:
If CHLD_ERR is false, or the same file descriptor as CHLD_OUT, then
STDOUT and STDERR of the child are on the same filehandle. The
CHLD_IN will have autoflush turned on.
and $err is undef, which is clearly false. But what would be the
correct way to call open3?
The following works:
#!/usr/bin/perl
use IPC::Open3;
use Symbol;
use Data:umper;
my ( $in, $out, $err );
$err = gensym;
open3($in,$out,$err, "/usr/bin/sort");
print Dumper [$in, $out, $err];
__END__
but calling gensym by hand seems oldschool. But is there a better way?
//Makholm
filehandle not being used. Try the following script:
#!/usr/bin/perl
use IPC::Open3;
use Data:umper;
my ( $in, $out, $err );
open3($in,$out,$err, "/usr/bin/sort");
print Dumper [$in, $out, $err];
__END__
I would expect output like:
$VAR1 = [
\*Symbol::GEN0,
\*Symbol::GEN1,
\*Symbol::GEN2,
];
but I get output like
$VAR1 = [
\*Symbol::GEN0,
\*Symbol::GEN1,
undef
];
Reading the documentation, it clearly states that:
If CHLD_ERR is false, or the same file descriptor as CHLD_OUT, then
STDOUT and STDERR of the child are on the same filehandle. The
CHLD_IN will have autoflush turned on.
and $err is undef, which is clearly false. But what would be the
correct way to call open3?
The following works:
#!/usr/bin/perl
use IPC::Open3;
use Symbol;
use Data:umper;
my ( $in, $out, $err );
$err = gensym;
open3($in,$out,$err, "/usr/bin/sort");
print Dumper [$in, $out, $err];
__END__
but calling gensym by hand seems oldschool. But is there a better way?
//Makholm