Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: close and autodie on pipes

by runrig (Abbot)
on Jun 29, 2012 at 19:55 UTC ( #979174=note: print w/replies, xml ) Need Help??


in reply to close and autodie on pipes

If you want to catch exceptions, use eval:
my $result = eval { close $fh }; unless ($result) { print "Got an error: $@\n"; }
Or even:
my $result = eval { open my $fh, '-|', 'bash -c "echo Hello; exit 1"'; print for <$fh>; close $fh; }; ...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://979174]
help
Chatterbox?
[MidLifeXis]: I almost think that the coach is benching me. WTH?
[1nickt]: MKE?
[MidLifeXis]: MKE
[marto]: Milwaukee

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2017-03-23 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (286 votes). Check out past polls.