use Debug (1);
print "This is the program\n";
DEBUG { print "Debugging mode is ON\n"; };
print "Program continues...\n";
####
use Debug (1);
use Debug (0, DBG_SPECIAL);
DEBUG { warn "First type\n"; };
DBG_SPECIAL { warn "Second type\n"; }
####
# This goes in Debug.pm...
package Debug;
use strict;
sub doit (&) {
my $cref = shift;
$cref->();
}
sub dontdoit (&) {}
# Export appropriate one as DEBUG
sub import {
shift;
my $package = caller || '';
my $name = $_[1] || 'DEBUG';
{
no strict 'refs';
* { "${package}::$name" } =
(@_ && $_[0]) ? \&doit : \&dontdoit;
}
}
1;