|
Unraveling Code with the Debugger
|
|
|
| 2.5/5.0 (2 votes total) |
|
|
|
Daniel Allen June 05, 2006
|
Daniel Allen |
Daniel Allen is a software developer and Linux sysadmin living in Southern Ontario. He is a founding member of Kitchener-Waterloo Perl Mongers.
|
Daniel Allen
has written 1 tutorials for CGIDir. |
View all tutorials by Daniel Allen... |
Many people who work with Perl code never touch the debugger. My goal
in this article is to provide reasoned argument for adding the Perl
debugger to your set of tools, as well as pointers on how to do so.
Many people are most comfortable with adding debugging variables and
print statements to their code. These are fine techniques; I use them
too, when they are appropriate. At other times, the debugger has saved
me from tearing my hair out.
To mangle an old saying, with apologies to Sartre, "Hell is other
people's code." Other people think differently than I do; they use
weird idioms, and sometimes their comments are incomprehensible.
Invoking the debugger on someone's code is like having a conversation
with the author. It opens the code to the questions I want answered, in
real time--and there's another party in the conversation, the Perl
interpreter. The debugger makes it easy to try things out, even quicker
than writing a one-liner, because the environment's already set up for
the running program.
This article is a case example of using the Perl debugger in a
production environment. In this situation, we had problems with CGI
scripts on a machine I don't maintain. I wanted to go in, solve the
problem, and get out quickly, without unnecessarily changing anybody's
code. Read on... |
|
|