Sure, you could do whatever you wanted, really. Personally I like to die when something seems like an obviously fatal error. That doesn't mean that your *program* will die, because you can catch the die in an eval block. Which is what I do.

You also said:

> The die clause still returns > a false value for the sub call, right?
Well, no; the die just *dies*. Your sub won't return at all. Your program will die, unless you have an eval block, in which case the die will shoot you out to the closest eval block, and will populate $@ with the error message. And then you said:
> But this could cause > errors if not handled in the main clause, right?
Certainly. That's why the errors should be handled. :)

Instead of dying, then, you could have your sub return a false value. That would work. Then you could do your checking out in the caller. Some people find that preferable, I'm sure, and that's fine; my preference is to throw exceptions as soon as something bad happens. Then I catch them.


In reply to Re: Re: Re: multiple db connects by btrott
in thread multiple db connects by jasmine

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.