in reply to How to return an appropriate error from module?
As a (further...) general comment, this is exactly the sort of situation where I find it very useful to employ Perl objects. (As many CPAN modules do.)
Basically, what you do is to “instantiate a new Perl object,” then “call a method to determine the result.” The method-call will dutifully return a response that is true-or-false ... but because you are talking to an object, the method can also quite-easily store an error-code for your subsequent retrieval.
It's easy to understand, it's reasonably efficient, and it works well in practice. The “overhead” is actually quite negligible, and I find myself employing this metaphor for a lot of things. A Perl object turns out to be a very handy “container for context.” You can instantiate it, use it for as long as you need to, and then just let it go ... without feeling guilty.my $foo = My::Verifier::Module->new(); if (!$foo->validate($number)) { print "You can't do that because $foo->error_message\n"; };