Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: I never use the debugger.

by astroboy (Chaplain)
on Jul 27, 2005 at 10:57 UTC ( [id://478548]=note: print w/replies, xml ) Need Help??


in reply to I never use the debugger.

I'm sure that using the debugger from the command line can be a pain, but if you use an IDE (OptiPerl in my case, but Komodo has it too), then why spend the effort typing prints when you can step through the code, inspect variables in real time, set breakpoints - in other words save the the time keying in statements that you'll want to remove later.

Having said that, I make extensive use of Log::Log4perl because I can leave in the debug statements but turn off the generation of log messages when I want to.

Replies are listed 'Best First'.
Re^2: I never use the debugger.
by Anonymous Monk on Jul 27, 2005 at 11:36 UTC
    I use print statements because that'll save me time stepping through code, setting breakpoints, etc.

    I'm often interested in the value of a variable after a few thousand iterations in a loop. I really don't want to step through that code, or set a breakpoint in that loop. Takes way too much time.

      There's nothing to say you can't do a hybrid approach if you're debugger is being annoying... which the perl debugger is sometimes. :-(

      Add a debugging conditional for the nth line of the loop, and set a breakpoint at it.

      In my experience, though, if I'm interested in the thousandth interation of something, there's something happening (a particular record, or database entry, or something) that triggers my interest in the 1,000th time through the loop versus the 999th time.

      If I can identify what that is, I can write debug code to detect the suspicious condition, and set a breakpoint for that. Then I can decide what to print out, and where to investigate from there.

      Unfortunately, the perl debugger doesn't seem to have a "detect this condition and break" function, and I sure wish it did. I consider it a flaw in the debugger when I have to write debug code by hand, but it's better than writing *all* the debug code by hand, only to tear it *all* out later...

        Hmmm?

        b My::App::some_function $_[3] > 999
        Sets the breakpoint on My::App::some_function only if the 4th argument is numerically larger than 999. Similar structure for line breaks:
        b 215 $i > 999
        I use it all the time. It's invaluable.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://478548]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-24 21:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found