There is no spoon.
Seriously though, I beleive that the flash that you where refering to is when you realize that you did it wrong in the 1st place. I rarely use perl's debugger. At most, I run -c just to see if I don't have a typo somewhere, but TRUE debugging, very rare. Mind you, that, I'm not a programing super-hero or anything of the sort. Its just my way of doing things.
When scoping through code, instead of trying to find the logic in what was just written, I find it more productive to review the logic itself and what it was I was trying to accomplish in the 1st place (ie: read it as if I were reading perlmonks). This is a habbit I aquired when reviewing trainees' coding. I always ask myself, "How would I do it?" even if the code is mine. I just pretend it isn't.
Invariably, I'll hit the bad spot (if it isn't just a typo) during the 1st run through. Else, I give it to someone else to read and come back to it later. It also helps to explain out loud why each line is written the way it is.
Just my R$0.02 (Brazilian two cents) worth.
| [reply] |
I used to debug a lot like you do, it works fine. Another
good trick is to abuse Data::Dumper for debugging when
diving into data structures and objects. But these all
can be trememdously slower sometimes, especially if the original
code is not yours. I did not really start using
debuggers until I got to my current job where some of the
programs are 30k lines long, none of which were written
by me. They are not a bad sized programs,
but some were written in the most bizzare way, and no
strict. Yet I still have to fix the bugs that are reported.
It is hard to get into debuggers at first, but
investigate some of the gui ones like Devel::ptkdb or DDD.
Getting really familiar with a good debugger is (in my opinion)
one of the most advantageous things any programmer can do.
| [reply] |