Perl: the Markov chain saw | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
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.
-- In reply to Re: Turning a script into a module
by barbie
|
|