Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: eval to replace die? (Exceptions and Error Handling References)

by eyepopslikeamosquito (Archbishop)
on Oct 04, 2010 at 03:36 UTC ( [id://863236]=note: print w/replies, xml ) Need Help??

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";
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-18 22:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found