Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Pipe Error Trapping

by dpuu (Chaplain)
on Aug 24, 2004 at 16:13 UTC ( #385434=note: print w/ replies, xml ) Need Help??

in reply to Pipe Error Trapping

When opening a command to a pipe, the open command will only fail if the command you're trying to run (gzcat) doesn't exist. You need to check if the command found an error, after it started running.

The solution is to check the return value of other functions -- specifically, the close function:

open IN, "cat foo|" or die "failed to open: $!"; while (<IN>) { print } close IN or die "failed to close: $!";
Opinions my own; statements of fact may be in error.

Comment on Re: Pipe Error Trapping
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://385434]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2015-11-26 16:21 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (701 votes), past polls