On Thu, 2004-05-27 at 13:08, Nathanial P. Hendler wrote:
> I guess I just don't quite know how to do that. Is there a way to have a
> module run anycode any time another perl module/script uses it?
>
> use Debug;
>
> would executed insided Debug.pm
>
> IM_BEING_USED {
> $D = 0;
> }
There is. When you do a "use Debug" it looks for a sub called
Debug::import and runs it if one is found. However, the use statement
happens only once, at compile time, not on every request.
If what you want is a flag that you can set which lasts only for the
length of a request, do it like this:
(Assuming that $r is the request object)
$r->pnotes('debug') = 1;
The pnotes structure is like a hash that gets cleared after every
request.
Ultimately, I would recommend that you just move to using Log::Log4Perl
instead. It has tons of flexibility in how you set debug levels.
- Perrin
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html