3 package Pod::Simple::Debug;
5 use vars qw($VERSION );
14 ($variable, $value) = @_[1,2];
16 ($variable, $value) = ($value, $variable)
17 if defined $value and ref($value) eq 'SCALAR'
18 and not(defined $variable and ref($variable) eq 'SCALAR')
19 ; # tolerate getting it backwards
21 unless( defined $variable and ref($variable) eq 'SCALAR') {
23 Carp::croak("Usage:\n use Pod::Simple::Debug (NUMVAL)\nor"
24 . "\n use Pod::Simple::Debug (\\\$var, STARTNUMVAL)\nAborting");
28 Carp::croak("Usage:\n use Pod::Simple::Debug (NUMVAL)\nor"
29 . "\n use Pod::Simple::Debug (\\\$var, STARTNUMVAL)\nAborting");
32 if( defined &Pod::Simple::DEBUG ) {
34 Carp::croak("It's too late to call Pod::Simple::Debug -- "
35 . "Pod::Simple has already loaded\nAborting");
38 $value = 0 unless defined $value;
40 unless($value =~ m/^-?\d+$/) {
42 Carp::croak( "$value isn't a numeric value."
43 . "\nUsage:\n use Pod::Simple::Debug (NUMVAL)\nor"
44 . "\n use Pod::Simple::Debug (\\\$var, STARTNUMVAL)\nAborting");
47 if( defined $variable ) {
48 # make a not-really-constant
49 *Pod::Simple::DEBUG = sub () { $$variable } ;
51 print "# Starting Pod::Simple::DEBUG = non-constant $variable with val $value\n";
53 *Pod::Simple::DEBUG = eval " sub () { $value } ";
54 print "# Starting Pod::Simple::DEBUG = $value\n";
68 Pod::Simple::Debug -- put Pod::Simple into trace/debug mode
72 use Pod::Simple::Debug (5); # or some integer
77 use Pod::Simple::Debug (\$debuglevel, 0);
78 ...some stuff that uses Pod::Simple to do stuff, but which
79 you don't want debug output from...
82 ...some stuff that uses Pod::Simple to do stuff, but which
83 you DO want debug output from...
89 This is an internal module for controlling the debug level (a.k.a. trace
90 level) of Pod::Simple. This is of interest only to Pod::Simple
96 Note that you should load this module I<before> loading Pod::Simple (or
97 any Pod::Simple-based class). If you try loading Pod::Simple::Debug
98 after &Pod::Simple::DEBUG is already defined, Pod::Simple::Debug will
99 throw a fatal error to the effect that
100 "it's s too late to call Pod::Simple::Debug".
102 Note that the C<use Pod::Simple::Debug (\$x, I<somenum>)> mode will make
103 Pod::Simple (et al) run rather slower, since &Pod::Simple::DEBUG won't
104 be a constant sub anymore, and so Pod::Simple (et al) won't compile with
112 use Pod::Simple::Debug (5); # or some integer
114 is basically equivalent to:
116 BEGIN { sub Pod::Simple::DEBUG () {5} } # or some integer
121 use Pod::Simple::Debug (\$debug_level,0); # or some integer
123 is basically equivalent to this:
126 BEGIN { $debug_level = 0 }
127 BEGIN { sub Pod::Simple::DEBUG () { $debug_level }
134 The article "Constants in Perl", in I<The Perl Journal> issue
135 21. See L<http://interglacial.com/tpj/21/>
139 Questions or discussion about POD and Pod::Simple should be sent to the
140 pod-people@perl.org mail list. Send an empty email to
141 pod-people-subscribe@perl.org to subscribe.
143 This module is managed in an open GitHub repository,
144 L<http://github.com/theory/pod-simple/>. Feel free to fork and contribute, or
145 to clone L<git://github.com/theory/pod-simple.git> and send patches!
147 Patches against Pod::Simple are welcome. Please send bug reports to
148 <bug-pod-simple@rt.cpan.org>.
150 =head1 COPYRIGHT AND DISCLAIMERS
152 Copyright (c) 2002 Sean M. Burke.
154 This library is free software; you can redistribute it and/or modify it
155 under the same terms as Perl itself.
157 This program is distributed in the hope that it will be useful, but
158 without any warranty; without even the implied warranty of
159 merchantability or fitness for a particular purpose.
163 Pod::Simple was created by Sean M. Burke <sburke@cpan.org>.
164 But don't bother him, he's retired.
166 Pod::Simple is maintained by:
170 =item * Allison Randal C<allison@perl.org>
172 =item * Hans Dieter Pearcey C<hdp@cpan.org>
174 =item * David E. Wheeler C<dwheeler@cpan.org>