Badger::Debug
package Your::Forager; use base 'Badger::Base'; use constant DEBUG => 0; our $MESSAGES = { foraging => 'Foraging in the %s for %s', }; sub forage { my ($self, $where, $what) = @_; $self->debug_msg( foraging => $where, $what ) if DEBUG; # ... do some foraging... }
Thus Spake Andy:
If you set a DEBUG
constant instead then Perl is smart enough to optimise
away the entire debugging line when it compiles the program. The upshot is
that there's is no runtime overhead whatsoever with these kind of debugging
statements. The downside is that you have to go and edit the source code
to change 0
to 1
when you want to enable debugging. Or do you?....