> ...
> Thanks for your detailed explanations. I think that close should work
> as I cannot see any reason why a failure of a command closes the pipe
> prematurely.

Actually,  everything is ok until the close which checks both the
status from reaping the child and the close itself:

The open can actually  be written like this for more into:

my $pid = open(my $fh, '-|', ... or die ...;   # pid is forked process id
warn "made it past open ok...\n";
close( $fh) or die "child $pid status=$?  close error=$!";

So the close can be written  to see whether the child  process had a
problem, ie, $?  or whether it was  the 'close' itself that failed, ie, $!.

Output without 'autodie':
 made it past open ok...
 child 4872 status=256  close error=Inappropriate I/O control operation
at...

With autodie though, the message is much more obscure:
 made it past ok...
 Can't close(GLOB(0x64dcf8)) filehandle: '' at...

-- 
Charles DeRykus

Reply via email to