Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How do I get output from the perl debugger (perl -d) into a text file?

by tlm (Prior)
on Aug 02, 2005 at 04:00 UTC ( [id://480074]=note: print w/replies, xml ) Need Help??


in reply to How do I get output from the perl debugger (perl -d) into a text file?

Two ideas that have not been mentioned (but may only work on Unix) are the following. You can prepend a pipe symbol | before debugger commands to get paged output. (I have heard that H. redmondiensis knows about the wheel and the inclined plane, so maybe he also knows about pagers.)

% perl -de 1 Loading DB routines from perl5db.pl version 1.23 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 1 DB<1> %hash = 1..100 DB<2> |x \%hash ~ ~ ~ 0 HASH(0x8447fb4) 1 => 2 11 => 12 13 => 14 15 => 16 17 => 18 19 => 20 21 => 22 23 => 24 25 => 26 27 => 28 29 => 30 3 => 4 31 => 32 33 => 34 35 => 36 37 => 38 39 => 40 41 => 42 43 => 44 39%

(Those squigglies before the paged output and the 39% at the bottom are courtesy of my default pager, /usr/bin/less.)

In fact, though this is the default behavior when one prepends a | to commands, you can customize this significantly, to tell the debugger where to send its output.

DB<3> o pager Option `pager' is non-boolean. Use `o pager=VAL' to set, `o pager?' t +o query DB<4> o pager? pager = '|/usr/bin/less' DB<5> o pager='>> /tmp/capture' pager = '>> /tmp/capture' DB<6> |x %hash DB<7> |X DB<8> o pager='|/usr/bin/less' pager = '|/usr/bin/less'

In <5> I change the pager option from its default '|$ENV{PAGER}' (where, in your typical halfway civilized Unix system, PAGER is an environment variable that holds one's default pager), to '>> /tmp/capture'. This means that the output of debugger commands prepended by | (in this case, those on <6> and <7>) will now be appended to the file /tmp/capture. In <8> I restore the original value of pager.

the lowliest monk

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://480074]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 23:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found