in reply to Can someone tell me why this hangs??
After a few months I discovered the Perl Debugger -- perl -d; I have not gone back to print statements, except as a last resort (and usually in CGI coding).
I step through the code until the code takes off in a different direction from what I expected. I look at the variables involved in the control construct that surprised me. I track back to where the erroneous value appeared, fix my bug and go on.
Whether one method or the other is 'better' is not something that I can really say. I get a better feel for the logic by watching the way the Program flows as I step from point to point in the execution. I know other programmers who can parse the logic-flow as they read the code, and decide on where they want to insert debugging statements based on their mental map of the logic. It all depends on what you are comfortable with.
----
I Go Back to Sleep, Now.
OGB
|
|---|