- or download this
use feature 'try';
try {
...
catch ( $e ) {
warn "It failed - $e";
}
- or download this
use feature 'try';
try {
...
finally {
cleanup();
}
- or download this
use strict;
use warnings;
...
# oops, handle FH is still open if an exception was thrown.
my $line = <FH>;
print "oops, FH is still open:$line\n";
- or download this
use strict;
use warnings;
...
my $ok = eval { fred(); 1 }; # see [id://11130946]
if (!$ok) { print "died: $@\n" }
print "ok, \$fh is auto-closed when sub fred exits (normally or via di
+e)\n";