RE: Enable Perl Debugging at Run-Time
From: David Le Blanc (david.leblanc_at_identity-solutions.com.au)
Date: 03/10/04
- Next message: Flemming Greve Skovengaard: "Re: Problem recording the first digits into a scalar"
- Previous message: Stuart White: "Re: backreferences"
- Maybe in reply to: David Le Blanc: "Enable Perl Debugging at Run-Time"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 10 Mar 2004 14:01:19 +1100 To: "zentara" <zentara@highstream.net>, <beginners@perl.org>
> -----Original Message-----
> From: zentara [mailto:zentara@highstream.net]
> Sent: Wednesday, 10 March 2004 1:41 AM
> To: beginners@perl.org
> Subject: Re: Enable Perl Debugging at Run-Time
>
> On Tue, 9 Mar 2004 12:07:18 +1100,
> david.leblanc@identity-solutions.com.au (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: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
- Next message: Flemming Greve Skovengaard: "Re: Problem recording the first digits into a scalar"
- Previous message: Stuart White: "Re: backreferences"
- Maybe in reply to: David Le Blanc: "Enable Perl Debugging at Run-Time"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|