|XP is just a number|
Re^3: Unbelievably Obvious Debugging Tipby radiantmatrix (Parson)
|on Dec 15, 2004 at 00:05 UTC||Need Help??|
Because I often deal with data containing every char on the keyboard, I use:
This gives me an output with visible record separators (ASCII 0x1E is actuall "Record Separator") quite cleanly, and I use STDERR to avoid bufferring. Default buffering of STDOUT has bitten my debug routines a few times.
If I'm working a large project, I use my own little module that exports a number of debugging "tools", including this:
The open_logfile sub returns an opened file handle, or opens a new one if need be, to "DEBUG.LOG". Debug items are written to STDERR unless I set $QUIET, and they are always written to the logfile, prepended by a timestamp.
And, of course, if I unset $DEBUG, then it's basically a no-op.
Run the following with 'you stupid foo' as arguments:
#DEBUG.LOG 20041214:17.58.22▲Hello there▲ 20041214:17.58.22▲You fool▲ 20041214:17.58.22▲ARGV:▲ 20041214:17.58.22▲$VAR1 = [ 'you', 'stupid', 'foo' ]; ▲ #STDERR Hello there▲ You fool▲ ARGV:▲ $VAR1 = [ 'you', 'stupid', 'foo' ]; ▲
It works quite well. The '?' you might see actually shows up as an upward triangle in a terminal, so it is very clear.