Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
nbezalla:

Okay ... now that I've answered your second question, I guess I should address the first one.

Generally, when I debug a long-running while loop, I'll use one (or more) of the following techniques:

  • If each iteration is relatively quick and simple, I'll first use the perl debugger to step through the first few iterations to get a feel for things.
  • If there are plenty of alternate execution paths, I'll set a breakpoint in *all* of them, then start the program. As I reach each new breakpoint, I'll step through to the end of the loop, looking for something odd. When I hit the end of the loop, if I found nothing interesting in that path, I'll remove the breakpoint that I tripped and continue execution. After a while, you'll usually reach the point where the fault occurs relatively quickly.
  • Sometimes, I'll just pepper the loop with print statements showing the values of variables I'm concerned about, to see what's happening.
  • If the fault seems to occur with the same data each time, then I'll use the debugger and set the variables up to cause the fault immediately, then step through the code and see where my bug is.
  • I hope this is useful...

    ...roboticus


    In reply to Re: How to debug a long while loop by roboticus
    in thread How to debug a long while loop by nbezzala

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



    • Are you posting in the right place? Check out Where do I post X? to know for sure.
    • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
      <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
    • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
    • Want more info? How to link or How to display code and escape characters are good places to start.
    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others sharing their wisdom with the Monastery: (2)
    As of 2024-04-26 00:57 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found