in reply to (tye)Re: XML::Parser and the utf8 Pragma
in thread XML::Parser and the utf8 Pragma

I'll look into it, thanks. Why the issues with sig handlers? My intention, by the way, is to avoid using "die" statements as much as possible. The die and warn handlers i've installed for this set of scripts is to catch anything i hadn't thought to catch, or is out of my control (like when xml parser craps out on you... not happy there isn't a hook into it's error handling abilities). The idea for the former, of course, is to go in and take care of the exceptions.
  • Comment on Re: (tye)Re: XML::Parser and the utf8 Pragma

Replies are listed 'Best First'.
(tye)Re2: XML::Parser and the utf8 Pragma
by tye (Sage) on May 11, 2001 at 06:50 UTC

    Well, real signal handlers have their own problems that I won't go into here. One problem with both __WARN__ and __DIE__ handlers is that they are single-slot globals so if you want to use them then you had better hope that none of the modules you use had a use for them either or you are going to "bump heads".

    Other than the above, __WARN__ handlers don't bother me and are an okay way to catching warnings. If you have new enough Perl, then I think you can instead use warnings.

    If you just want your warnings and errors to end up in a log file, then I'd simply redirect STDERR and avoid all this fancy stuff!

    __DIE__ handlers on the other hand have several design problems and the alternative, eval and $@, don't have these problems, so I always encourage the use of eval {...} in place of the __DIE__ handler. __DIE__ handlers also look deceptively easy so people often choose them over eval.

    Some of the problems with __DIE__ handlers: They get called even inside eval so you run the risk of reporting errors that you shouldn't or of making non-fatal non-errors into fatal errors. Also, if you use eval (instead of a handler), you don't have these problem and you also don't have the problem of "bumping heads" with other modules that want to use eval.

    Also, eval "..." has a (partially deserved) reputation for being "slow" so people are often shy to use eval {...}.

            - tye (but my friends call me "Tye")