package DEBUG; use strict; sub import { my $pkg= shift @_; my $default= 1; if( @_ && 'inherit' eq $_[0] ) { return if defined \&::DEBUG; shift @_; $default= 0; } if( @_ && $_[0] =~ /^(on|off)$/ ) { $default= 'on' eq $_[0] ? 1 : 0; shift @_; } if( @_ ) { require Carp; Carp::croak( "Usage: use DEBUG ['inherit',] ['on'|'off'];" ); } eval "sub ::DEBUG() { $default; }; 1" or die $@; } sub unimport { if( 2 < @_ || 2 == @_ && 'inherit' ne $_[1] ) { require Carp; Carp::croak( "Usage: no DEBUG ['inherit'];" ); } import(@_,'off'); }