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
-
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.
|