I have convention in which i use warn for debug output, and
prefix output with ## up to warning level
This then gets passed through $SIG{__WARN__} which filters
messages which I don't want to see.
use strict;
use base 'Exporter';
-our @EXPORT = qw( hex2bytes as_hex hex_tag );
+our @EXPORT = qw( hex2bytes as_hex hex_tag $debug );
use Data::Dump qw(dump);
our $VERSION = '0.02';
-my $debug = 0;
+our $debug = 0;
=head1 DESCRIPTION
sub hex_tag { uc(unpack('H16', shift)) }
+=head1 WARN
+
+We are installing L<perldoc/warn> handler to controll debug output
+based on C<$Biblio::RFID::debug> level
+
+=cut
+
+BEGIN {
+ $SIG{'__WARN__'} = sub {
+ my $msg = join(' ', @_);
+ if ( $msg =~ m/^(#+)/ ) {
+ my $l = length $1;
+ return if $l > $debug;
+ }
+ warn join(' ', @_);
+ }
+}
+
=for readme continue
=head1 HARDWARE SUPPORT