Problems? Is your data what you think it is? | |
PerlMonks |
Re: Re: Re: Idomatic Handling of Subroutine Errorby dragonchild (Archbishop) |
on Sep 18, 2001 at 23:35 UTC ( [id://113183]=note: print w/replies, xml ) | Need Help?? |
You're almost there.
You actually do a die which doesn't end your script - it gets trapped by the eval and the string you passed die will be put in $@. Now, I personally dislike this type of error-handling because 0 is FALSE and non-zero is TRUE. Thus, you have to flip your thinking the way the C libs force you to and say you're calling the function and hope it "fails" for success. (Sorta like a drug screening ...) Instead, I would something similar. Instead of passing back '' for success, I'd pass back undef instead. It seems like a semantic difference, but now your code use TRUE and FALSE the way they intuitively used, to indicate success and failure. ------ Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
In Section
Seekers of Perl Wisdom
|
|