Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Perl's debugger is a command line debugger, so while it's not pretty, with buttons and little red lines for your breakpoints, it can be pretty durn effective once you get used to it. This isn't so much of a tutorial as a brief overview of the most common commands.

Invoking

bash$ perl -d myscript.pl
This will put you in the command line mode. It looks like:

main::(perl/test.pl:5): print "Just another perl monk\n";
__DB<1>__

Dissecting it, we have this information:

Module::(sub module)::function(physical file location:line number): current line of code;

now you can type in whatever you want to make your program proceed.

Know your command set!

Here's a few of the more often-used commands:

  • n -- next. Proceed to the next command
  • s -- step (in). If you are in a function call, proceed to that function.
  • x -- eXecute. Although it's more like eval. This lets you monitor variables, or execute arbitrary code. "x $FOO" will print out the value of $FOO, etc. It will automatically expand references, which is nice if you are using complex data structures.
  • b LINE -- Set a breakpoint on the target line. This way when you use "c", it will stop at the breakpoint
  • c -- continue running until breakpoint.
  • T -- print the call stack of functions
  • <enter> -- repeats the last command. Useful when preceeded by "n" or "s".
  • h -- help. Prints out a much more comprehensive command list than this...
  • q -- quit.

    What? More functionality?

    Of course there's a hell of a lot more functionality! Check out the perldebug man page...


    In reply to Using the Perl Debugger by root

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post; it's "PerlMonks-approved HTML":



  • 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, 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, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (3)
    As of 2017-12-16 06:40 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      What programming language do you hate the most?




















      Results (449 votes). Check out past polls.

      Notices?