I suggest using subroutine constants that are set in a BEGIN block before the module is loaded with use. This way the test mode/debugging code has no performance or memory hit at runtime due to constant folding. Make sure to check with
that test mode code was fully removed from the opcode tree, it is very easy to break constant folding. I have a problem with seeing 2-8 parameter debug subroutine calls every 3-6 lines in a CPAN module to enable console printing debugging (as if Perl doesn't have a debugger with a watch window).