Rather than thinking about warn and die when something goes wrong, think about return codes.
If something goes horribly wrong, I usually return undef, then the caller can check whether anything was returned and handle it as it wishes. In some cases I also setup an internal error code and/or error message (ERRNO, ERRMESS), which can be accessed like Package::ERRNO. This then puts the reliance on the caller to handle the errors as they see fit.
Regards having a PrintHandler, passing that as you have seems fine, but if this is just for warnings and errors, I would personally use the return codes. Then again if this is for own use then it probably isn't an issue, if it was for CPAN you might want to consider that others might not want to print anything at all.
--
Barbie | Birmingham Perl Mongers | http://birmingham.pm.org/
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.