I'm writing a module and I'd like scripts using it to be able to turn on
debugging. At first, I wanted use a very simple interface like Storable
does,
$Storable::forgive_me = 1;
But then it occurred to me that perhaps I would be able to be a little
more flexible with a sub. So I came up with something like this:
Package DebugMe;
use vars qw( $dl ); # debug level
sub debug {
use Carp;
use Data::Dumper;
$dl |= shift;
}
# so the usage would be this:
DebugMe::debug( 1 ); # change debugging level to 1
DebugMe::debug( 2 ); # change degbugging level to 2
However, I dont want the user to have any warnings if they arent
interested in debugging because they dont have Data::Dumper or (isnt it
part of the core) Carp. I looked through perldoc perlmod and also through
perldoc -f use and perldoc -f require. I havent seen whether it gets use'd
every time, or whether it only gets called when its needed.
Could somebody clarify this for me?
Thanks,
brother dep.
--
Laziness, Impatience, Hubris, and Generosity.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.