The single most powerful debug tool in Perl is "print" and Data::Dumper and its kinfolk like Data::Dump. Why is not modifying the program a requirement? Why not just add some print statements and be done with it?
During debug, I add print statements all the time with a comment tag field to make them easy to delete later (my program editor makes that easy). The "change code, recompile, execute code" cycle is so fast (if you have a good development environment) in Perl that modifying the code to debug it is very sensible.
Sometimes I will leave some debug statements in the code. These are things that I am likely to need later if there is some significant modification to the code.
In Perl if you set DEBUG =>0, there is no speed penalty for that if statement because Perl knows due to the constant value that the code will never be executed and it is not even compiled.use constant DEBUG =>1; ... if (DEBUG){...code}
Maybe you can find all kinds of tricky debug statements to get the debugger to do what you want right now. However, you will not know that stuff years from now when you are debugging some modification. For the most part, I recommend using "print" for transient debug issues. For some code where modifications are likely to require examining some data structure, I put in in if(DEBUG).
In reply to Re: How can I print variable contents from the debugger non-interactively?
by Marshall
in thread How can I print variable contents from the debugger non-interactively?
by davehorner
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |