in reply to Re^3: Catching errors in closing lexical filehandles
in thread Catching errors in closing lexical filehandles
There are plenty of ways this could be improved, I'm sure. for one thing, the naming is just the first thing that came to mind.use closefail qw(:standard); use closefail { die "I'm not feeling so well: $!" };
One possible complication in implementing this, however, is that the scope of this declaration needs to include the closing of the current scope, if you pardon the pun. So you can say this:
Instead of:{ use closefail; open my $thing, $what or die "..."; # ... } # <- still in effect as this block ends
{ use closefail; { open my $thing, $what or die "..."; # ... } }
|
|---|