sub import { my $caller = scalar(caller); no strict 'refs'; my ($name_debug_flag, $name_debug_sub) = ("$caller\:\:DEBUG", "$caller\:\:debug"); *{$name_debug_flag} = 0; *{$name_debug_sub} = sub { $DEBUG or return 1; printf STDERR "%s() @_\n", (caller(1))[3] }; }

LEOCHARRE::Debug - debug sub

use LEOCHARRE::Debug;
debug('hey there');
warnf '%s %s %s\n', 'this', 'is', 'a value';

Exported.
Works like
warn sprintf '', @args


Leo Charre leocharre at cpan dot org

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, i.e., under the terms of the "Artistic License" or the "GNU General Public License".

This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the "GNU General Public License" for more details.