Doubt in Perl exception handling

From: Babu (babu.subburathinam_at_gmail.com)
Date: 03/10/05

  • Next message: Ryan Keeling: "Regex"
    Date: 9 Mar 2005 20:09:05 -0800
    
    

    Hi,
    I am a Perl newbie and have a doubt on Perl exception handling.
    My understanding regarding exception handling is execute a piece of
    code, if any exception occurs, handle the exception and proceed as if
    the error never occurred at all.
    So code would look like

    Eval {
      # do something
    }; if ($@)
    {
      #handle exception
     }
    #procees as if no exception occurred

    But in Perl I find that very often we die upon an exception. We never
    try to handle the exception and continue. Is my understanding correct?
    Is this the right way to do it?

    TIA,
    Babu


  • Next message: Ryan Keeling: "Regex"

    Relevant Pages

    • Re: Exception handling in class: question
      ... >> practice for exception handling or should they be sprinkled through code ... you were hiding your question in Perl verbiage. ... > Only use it if the exception can't be otherwise anticipated. ... The first form traps run-time exceptions that would otherwise prove fatal, ...
      (comp.lang.perl.misc)
    • Re: Exception raised in DBI.pm during Scalar::Util::weaken?
      ... a perl script to test the various operations of my database, ... But as soon as I incorporated my usual exception handling routine ... Am I to take it that DBI is just not reliable for use in a production ... if it takes only *five* lines of perl code to ...
      (perl.dbi.users)
    • Re: Exception Handling - Professionally
      ... I know there are a lot of ways Perl ... undef or the exception, or in the case I need a return value back I just ... At the time, I was weary of using the die/eval model, if I ... could deal in multiple types of exception/error handling, ...
      (perl.beginners)
    • Finding out the String-based Exceptions for a Module?
      ... I've noticed that most modules don't support Perl's exception objects with the PROPAGATE method but in stead carp or worse might die with a string-based exception, ... The obvious non-lazy solution would be to look in the module code and then manually pull apart any components in that string in which you might be interested, say using regexp matching and homing in at variable interpolated parts. ... for quite some time I've been wondering why there's no Perl module to parse Perl in a structured way splitting it into some sort of parse tree you could walk programmatically or using a set of callbacks much like a SAX parser would. ...
      (comp.lang.perl.misc)
    • Re: Doubt in Perl exception handling
      ... > I am a Perl newbie and have a doubt on Perl exception handling. ... Is my understanding correct? ...
      (comp.lang.perl)