[Mastering-perl] Debugging chapter comments
Derek B. Smith
derekbellnersmith at yahoo.com
Fri Oct 13 15:19:49 EDT 2006
--- "Derek B. Smith" <derekbellnersmith at yahoo.com>
wrote:
> --- brian d foy <brian.d.foy at gmail.com> wrote:
>
> > I've been busy lately. I think I've finished the
> > first pass on two
> > more chapters. Let me know if I left out any major
> > topics I should
> > have discussed. I'd especially like everyone to
> look
> > at these chapters
> > and ask themselves "Would my co-worker learn
> > everything I want him to
> > know about this subject by reading this chapter?"
> If
> > your answer is
> > "No", let me know what else you want!
> >
> > I've added a bunch of stuff to the Debugging
> > chapter:
>
> Hi Brian,
>
> In YoUr DeBuGgiNg CHapTEr, (oops sorry about the
> case
> mix...still thinking I am on myspace :) under "Doing
> whatever I want" you mention modifying the %SIG hash
> which is good but I think you fail to clearly state
> the benefits of this. For example I use this code
> in
> my header template as a centralized die routine
> instead of having a bunch of dies with prints:
>
> my $overide = $SIG{__DIE__}; ## get error handler
> currently assigned 2 die
> $SIG{__DIE__} = sub {
> my $error = shift; ## error now holds the mesg
> passed to die
> $overide->($error) if ( ref $overide );
> print LOG ($error);
> };
>
> It looks like croak is a more informed version of
> DIE
> so I will make the switch. thank you.
>
> UNder Program tracing you state: Each subroutine
> call
> put a frame with all of its information onto the
> stack[4].
>
> It should read Each subroutine call can place a
> frame
> with all of its information onto the stack[4].
>
> Please define frame here!?
>
> In your final block of code explaining debugging do
> you intend this code to be a substitute for a
> centralized die/croak routine? Or do you intend
> this
> to serve as routine that will give the most detail
> that can be used in any situation b/c I notice you
> are
> checking if its a reference? I guess I was
> overwhelmed, but impressed so maybe "put it all
> together" in a final example.
>
> BEGIN {
> use Carp::Heavy;
>
> no warnings 'redefine';
> *Carp::format_arg = sub {
> package Carp;
> my $arg = shift;
>
> if( not defined $arg )
> { $arg = 'undef' }
> elsif( ref $arg )
> ...
> ...
> $arg =~
>
s/([[:cntrl:]]|[[:^ascii:]])/sprintf("\\x{%x}",ord($1))/eg;
> return $arg;
> };
> }
>
> Finally,
>
> I use Eclipse IDE and I love it. It offers spell
> checker, an integrated debugger with the padwalker
> module that runs perl5db under the covers and nicely
> displays all the information one needs to debug.
> Maybe pick your top 3 and go more in depth. My top
> 3
> would be Esclipe, Komodo and perl5db command line.
>
> thank you
> derek
>
I tested your example Carp code where you divide by
zero....I dod not see much benefit of using
Carp::croak or Carp::confess if one has diagnostics
turned on. I did not see you explain use diagnostics
at all?
thanks
derek
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Mastering-perl
mailing list