I've been a professional Perl hacker for the past five years, and a very amateurish amateur before that. Over the years my skills have improved tremendously (when I started my first fulltime job, I didn't know how to use references, for example.) I have proceeded from simple utility scripts to large OO systems, mod_perl, giant database frontends, daemons, simulators, GUI applications and all manner of miscellany, but I can't recall ever using the Perl debugger. In fact, I know almost nothing about it. It has been my attitude that
print is the most useful debugging tool, especially when coupled with
Data::Dumper. If something goes wrong, I sprinke some
prints here and there and watch the program flow. I spit out variables and instance data to make sure they are what I think they should be. If it's a daemon or background process, I log the debugging messages somewhere where I can look at them later. If it's a web-app, I like to send a
<pre> tag with some Dumper output so I can view the data right there in the rendered template.
I think there's perhaps two possible explanations for my not using the debugger.
- Perl is just so damn easy, and when you're running with strict and warnings, and avoiding common pitfalls, it's difficult to run into a problem so horrendous that the above methods can't solve it.
- I am simply not working on challenging enough projects, and the things I do are at such a rudimentary level that debugger-worthy problems simply don't arise.
Naturally the second possibility causes me some concern. I want to continue learning as much as possible, and if I have stagnated I haven't even realized it until I started this meditation.
So I'm interested in hearing the experiences of other Monks vis a vis Perl debugging techniques. Are there instances when the Perl debugger is invaluable, and mere printing or logging will not suffice? Are there times when you must step through a program, instead of narrowing down the problem to a few lines of code and spitting out the potentially broken variables? Or have you found that while my methods may work fine, using the debugger is easier or more efficient?
Eagerly awaiting your replies,
friedo
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.