> -----Original Message-----
> From: zentara [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, 10 March 2004 1:41 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Enable Perl Debugging at Run-Time
> 
> On Tue, 9 Mar 2004 12:07:18 +1100,
> [EMAIL PROTECTED] (David Le Blanc) wrote:
> 
> > 
> >Hey all.
> 
> > 
> >This works, however it would be neater if there was a command in perl
> >where
> >I could enable 'debug' and hence start tracing from a point. 
> While not
> >wasting
> >CPU cycles when debugging isn't enabled.
> 
> I'm not sure what you are doing, but this post from perlmonks rang a
> bell in my head.  Maybe it will give you an idea?
> 
> http://perlmonks.org?node_id=323875

That looks good.  It's a filter which removes 'debugging' code based on
POD style markup, where debugging is defined as 'code not required for 
normal operation'

What I would like to do, is to effect the perl '-d' flag from WITHIN a
script.

Under normal execution, perl does not keep debugging hooks active.
Hooks
such as DB::sub and DB::DB are only active while '-d' is in effect.


This particular script is one of many CGI's, so I don't have much scope
for interactive debugging, however tools like 'Devel::Trace' allow the
code to 'self trace' and dump trace data to STDERR.

I want to customise the trace module so that I can have it available
always
(have my cake) and be able to turn it on and off at run-time depending
on
the existence of [external] trace flags (and eat it too.).

The custom version would log the trace to a file which I could then
browse
with an editor after the fact to identify what is going wrong..

As I said,  I achieved this by tweaking the apache config to export an
empty 'PERL5DB' into the environment, and *always* run my script with
'-d'
enabled. (#!/path/to/perl -d -w)   I then install a 'DB::DB' handler
when I
want tracing to start, and uninstall it when I want tracing to stop.

sub trace_on() {        *DB::DB = \&tracer }
sub trace_off() {  delete ${DB::}{DB} }


> 
> 
> --
> I'm not really a human, but I play one on earth.
> http://zentara.net/japh.html
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> 
> 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to