Hello likbez,
you already received many good options and approaches, but your:
> BTW does Perl have a system variable "debug" that is global and does not need qualification with the package name?
prompts me for another answer: yes! you have %ENV at your disposal and you can create your own varaiable like DEBUG_TEMP that is uber global
#cat Example.pm
package Example;
use strict;
use warnings;
sub my_test{
print "output from sub\n";
print "package ",__PACKAGE__," spot debug!!\n" if $ENV{DEBUG_T
+EMP};
}
1;
#cat test-env.pl
use strict;
use warnings;
use lib '.';
use Example;
Example::my_test(); # test without the var
$ENV{DEBUG_TEMP} = 1;
Example::my_test(); # test with the var
#perl test-env.pl
output from sub # output before var setting
output from sub # two lines after var setting
package Example spot debug!!
# when the program exits, DEBUG_TEMP disappears
#perl -I . -MExample -e "Example::my_test()"
output from sub
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|