Enabling Debugging


$Your::Forager::DEBUG = 1;
require Your::Forager;


use Badger::Debug modules => 'Your::Forager';
use Your::Forager;
Thus Spake Andy:

You have to be a little bit careful to set that $DEBUG package variable before your module gets loaded. In the first example, we use require to load it at runtime after we've had a chance to set it. You can't use use because it's a compile time statement which Perl effectively moves up to the top of your script.

In the second example we let Badger::Debug take care of it for us by telling it the module(s) we want to enable debugging for. This itself is a compile-time use statement, so it's now safe to use your module on the next line.