The %SIG hash should avoid having to wrap your program in a huge eval. Is using %SIG not an option?
- David > From: Keary Suska <[EMAIL PROTECTED]> > Date: Thu, 25 Oct 2001 00:09:25 -0600 > To: David Iberri <[EMAIL PROTECTED]> > Cc: MacPerl List <[EMAIL PROTECTED]> > Subject: Re: [MacPerl] Trapping run time errors > > I would, except I can't quite predict where the error could happen, which > means I would have to eval the whole script, and being several thousands of > lines long, not including the modules I am loading, it really hurts > performance ;-) > > Keary Suska > Esoteritech, Inc. > "Leveraging Open Source for a better Internet" > >> From: David Iberri <[EMAIL PROTECTED]> >> Date: Wed, 24 Oct 2001 18:36:09 -0700 >> To: Keary Suska <[EMAIL PROTECTED]> >> Cc: MacPerl List <[EMAIL PROTECTED]> >> Subject: Re: [MacPerl] Trapping run time errors >> >>> Is there a way to trap runtime errors, and, say, output them to a log file >>> before perl dies? >> >> Often something as simple as this will do the trick: >> >> eval { >> ... # Some code that may call die() >> }; >> >> logmsg($@) if $@; # logmsg() is defined elsewhere to output >> # its argument to a log file. >> >> Or you could define closures for $SIG{__WARN__} and/or $SIG{__DIE__} that >> get called when warn() or die() are called, respectively, e.g.: >> >> local $SIG{__WARN__} = sub { logmsg(shift) }; >> >> HTH, >> >> David >> >>> Keary Suska >>> Esoteritech, Inc. >>> "Leveraging Open Source for a better Internet"