in reply to How can I print variable contents from the debugger non-interactively?
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).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can I print variable contents from the debugger non-interactively?
by Laurent_R (Canon) on Jul 15, 2017 at 08:39 UTC | |
|
Re^2: How can I print variable contents from the debugger non-interactively?
by karlgoethebier (Abbot) on Jul 15, 2017 at 10:26 UTC | |
|
Re^2: How can I print variable contents from the debugger non-interactively?
by davehorner (Scribe) on Jul 17, 2017 at 14:15 UTC | |
by Marshall (Canon) on Jul 19, 2017 at 00:51 UTC |