I've got a few debugging subroutines that I'd like to be TRULY global - that is, to be automatically exported into every package, so I can call them without a package prefix. This is for development only and I'm willing to resort to hackery to make it work.
So at the beginning of my application I do
#!/usr/bin/perl
use Debug;
and then in some module
package SomeModule;
dp $foo;
where 'dp' is one of the subroutines auto-exported by Debug. Note that SomeModule did not have to say 'use Debug' or 'Debug::dp'.
I figured this had to exist in CPAN, but several searches did not turn it up.
My initial idea was for Debug to
- Look for all existing packages in the symbol table and export into each one
- Push a subroutine onto @INC that captures each require as it happens, and then export the symbols into that new package.
Yes, this is the height of Laziness, as I could just type Debug::dp everywhere (or even d::dp if I named the package d.) But I figure with the saved keystrokes I might make up the development time by the end my programming life.
Thanks for any tips!
Jon
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.