Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^6: Multiple actions triggered by failure to open a file

by Anonymous Monk
on Jan 11, 2017 at 16:45 UTC ( [id://1179407]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Multiple actions triggered by failure to open a file
in thread Multiple actions triggered by failure to open a file

I'm influenced by Lisp's With-Open-File forms in wanting this code to look more like:
open my $log, '>>', $logfile and do { # lots of stuff to log 1; } || do { print "Failed to write log file $logfile: $!\n"; die "Failed to write log file $logfile: $!\n"; }
This has the interesting attribute that if the first do-block does not return true, the error handling block runs for it, possibly allowing multiple error types to be more-or-less gracefully handled together. For many things that's a benefit (but certainly not always)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-24 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found