[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Stupid debugger tricks



Here's a sort-of-documented-but-not-really trick I just discovered in the
perl debugger (this isn't strictly MacPerl, it works on Unix too, but it's
probably more useful on MacPerl.) That's the use of the | cmd and the pager
option.

I'm working on a script that generates some fairly large data
structures--hashes of hashes of arrays, etc., with a fair number of
elements at each level. I wanted to examine the data structure but a dump
of it is much larger than 32K, plus I didn't want to wait for the debugger
window to scroll it all.

Now, the perl debugger has a command (|) that runs another debugger command
with output piped to a pager. Of course Macs don't have pagers or pipes
(yet :-)), but the debugger lets you set what is opened when using the
pager, including a file! That was just what I needed. So I did something
like this to dump my data structures:

O pager">hash.out"
|x \%hash

This dumps the contents of %hash to the file hash.out, ready for my perusal
in BBEdit. You can also use >>, so:

O pager">>debug.out"
|cmd1
|cmd2
|cmd3

runs the three debugger commands, sending their output to the file
debug.out. And you can switch files whenever you want, so:

O pager">hash1"
|x \%hash1
O pager">hash2"
|x \%hash2
O pager">hash3"
|x \%hash3

dumps the contents of three hashes each to their own file.

Anyway, I find it useful, and hopefully someone else will too.

Brian



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch