I just figured out something I wanted for quite some time but never knew how to do and that is how to output stuff from a debugger-session into a file.

The use-case is the following: You debug a script and inspect a large data-structure via x $huge_reference.
Unfortunately this is really big and you would like to inspect it more closely in an editor, so you need to dump the structure into a file...

This is how to do it in the debugger:

First set up a pager like this: o pager=">my_file"
Then pipe the x-command through the pager like this: |x $huge_reference

That's it - "my_file" now contains the dump for you to inspect.

You can even set up a pager as ">>my_file" for appending.

I apologize for setting this up as a meditation as it may be common knowledge among Perl-hackers but it was new to me and I hope it might be useful for someone else as well.

Replies are listed 'Best First'.
Re: output to a file from the debugger
by iamsolarplexus (Initiate) on Mar 31, 2016 at 20:56 UTC

    This is an older thread but I do something similar though without changing configs. Maybe helpful / common knowledge again :)

    * My pager is 'less'; I left that as-is.

    * I pass the huge object to less in the same way: |x $huge_ref

    * Then from within less, I use its option to bring up the Save-to-Logfile prompt: -o

    I find that I send to the pager pretty regularly anyway, so this way I can save to a file more selectively. OP's idea is neat, too; this is just the way I like to do it.

Re: output to a file from the debugger
by Anonymous Monk on Jan 14, 2014 at 20:27 UTC
    Thank you - exactly what I needed!
      Yes - exactly what I needed too. Thank you for sharing. It would have been nice to have a command to do this, but knowing this workaround is VERY helpful. Big thanks.
Re: output to a file from the debugger
by Anonymous Monk on Jul 25, 2012 at 02:49 UTC