swartz has asked for the wisdom of the Perl Monks concerning the following question:
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
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Truly global subroutines - Auto-exporting symbols into all packages
by ikegami (Patriarch) on Dec 04, 2009 at 18:13 UTC | |
|
Re: Truly global subroutines - Auto-exporting symbols into all packages
by dirving (Friar) on Dec 04, 2009 at 18:42 UTC | |
|
Re: Truly global subroutines - Auto-exporting symbols into all packages
by AnomalousMonk (Archbishop) on Dec 04, 2009 at 18:50 UTC | |
|
Re: Truly global subroutines - Auto-exporting symbols into all packages
by MidLifeXis (Monsignor) on Dec 04, 2009 at 18:17 UTC |