Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I don't really want to dredge up all the tricks and traps I've come across dealing with these handlers, but I did want to at least mention the general attitude I came away with.

These handlers are one of the last bastions of action at a distance in Perl, and they cause no end of trouble. The best approach you can have to them is to avoid them entirely; however, some problems just don't seem to be as easily solved (or maybe solved at all) without them.

If you're writing a generic module to catch __DIE__ or __WARN__ that anyone can use, and that will interact well with other code trying to do the same thing, good luck. You'll need it. However, if you're trying to design a framework that will be largely consistent throughout it becomes a bit easier. I wrote a small web framework a long time back that relied on it. I wouldn't recommend it.

My best recommendation to avoid __DIE__ handlers in particular is to make heavy use of block eval and die. __DIE__ is essentially a try/catch design turned inside out; turning it back right-side in might be a far better approach.

In reply to Re: die/warn signal handler best practice questions by Somni
in thread die/warn signal handler best practice questions by bsb

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (1)
As of 2023-06-04 07:46 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (18 votes). Check out past polls.