The only way? Absolutely not. I know that adding print lines is the preferred method of debugging for some people, but in my mind an actual
debugger is by far the best tool.
Advantages for print statements:
- Simple - don't need to learn anything new.
Advantages for a debugger:
- Powerful - stepping, (conditional) breakpoints, actions, watchpoints, etc.
- Versatile - examine any value -- or the result of any expression -- at any point.
- Informative - dump complicated data structures, view stack traces, etc.
When perl5.6.1 is released, it will include a tutorial on using the debugger, written by Richard Foley.
Editor's note: thanks to davorg and neophyte for the
following information (combined into one answer for better
reference):
If you have trouble using the built-in debugger (see perldoc perldebug), check out the tutorial Using the Perl Debugger on this site.
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.