Help for this page

Select Code to Download


  1. or download this
    use feature 'try';
    try {
    ...
    catch ( $e ) {
       warn "It failed - $e";
    }
    
  2. or download this
    use feature 'try';
    try {
    ...
    finally {
       cleanup();
    }
    
  3. 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";
    
  4. 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";