in reply to Pattern for a shell-style call + error response

Since you appear to want to die whenever an error occurs, how about using an assertion?

#! perl -slw use strict; sub good{ 0 } sub bad{ 1 } sub assert { return unless $_[ 0 ]; die join( ' : ', caller, $_[ 1 ] ) . "\n"; } assert good(), 'Good() produced an error'; assert bad(), 'Bad() produced an error'; __END__ C:\test>junk5 main : C:\test\junk5.pl : 13 : Bad() produced an error

If the error string is always available from the library, you might move that into the sub to save some typing, though it would be easier if GetErrorCode() can be called as a class method rather than an instance method.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."