in reply to Debug flags

5.10.0 will feature assertions which can be active or inactive, which may do something of what you want. Also see the -P flag in perlrun.

If you are worried about overhead, you can do something like

# at the top use constant DEBUG => $ENV{DEBUG}; ... # later printDebug("some message") if DEBUG;
Here the function call and if check are optimized away when not debugging, leaving only a very small statement stub.