|Perl: the Markov chain saw|
Module for Printing Line Numbers in Debug?by QM (Parson)
|on Jan 21, 2013 at 12:04 UTC||Need Help??|
QM has asked for the
wisdom of the Perl Monks concerning the following question:
I have a library of modules I'm trying to debug, and I'd like to instrument some or all of them to output line numbers to STDERR, to help trace execution through some non-linear code, filled with lots of callbacks and such, where the normal code emitting quite a lot to STDOUT and STDERR.
Currently, I do a manual find/replace in the editor of big chunks of code, equivalent to this:
This of course makes the code hard to read, and doesn't work everywhere (I think use and package might have problems with this, maybe others.) Colleagues often get distracted with these, instead of seeing the important bits.
Really I'd just like a source filter or module I can invoke on the command line to safely do this between statements, and not muddy up the source code.
Update: I use a special script to run the script on a remote cluster of hardware that is not available locally. All files needed are copied over and untarred into an appropriate temp dir, the script run, and all STDOUT and STDERR reported back to the originating terminal.
Interactive debug would be my first choice, but the nature of the system makes it much easier to do s/// and print lines into the output logs.