tphyahoo has asked for the wisdom of the Perl Monks concerning the following question:

Monks, perl -d myprogram.pl puts me into the perl debugging environment. Is there some easy way I can get a complete listing of my activities here into a text file so that I can later examine what I did while in debug modus, rather than scrolling up and down in this ugly dos window? Thanks!
  • Comment on How do I get output from the perl debugger (perl -d) into a text file?
  • Download Code

Replies are listed 'Best First'.
Re: How do I get output from the perl debugger (perl -d) into a text file?
by Taulmarill (Deacon) on Aug 01, 2005 at 12:33 UTC
    if you are on a unix machine, something like perl -d myprogram.pl | tee logfile.log writes the output from perl into the logfile, but not your input.
    maybe that helps.
      Okay... tee for windows is downloadable at http://unxutils.sourceforge.net/. I'm trying it out now... and..

      It doesn't quite work. tee does print out to that log file, but it only seems to be printing what normally would be coming out of stdout. Perhaps if I could trap the stderr stuff into tee I would get the debug output as well. Any ideas?

        I'd recommend the unix 'script' command, but be warned -- it will also save control characters, which makes for some interesting reading if you try to pop it open in your favorite text editor.

        You can clean up a script file using the unix command 'col'.

        You can also use logging in your terminal program (tf or similar, if your current terminal doesn't support that function) or use something like 'screen'.

        Update: For those who aren't aware, windows users can make use of unix commands via programs like cygwin. Another useful command.com replacement is 4DOS and its siblings.

Re: How do I get output from the perl debugger (perl -d) into a text file?
by marto (Cardinal) on Aug 01, 2005 at 13:26 UTC
    The OP has stated that they are having to scroll up a DOS window.
    perlman:perldebug may help. See if you can set LineInfo to a file in the initialization options, something like:
    &parse_options("NonStop=1 LineInfo=db.out AutoTrace");
    Hope this helps.

    Martin
Re: How do I get output from the perl debugger (perl -d) into a text file?
by QM (Parson) on Aug 01, 2005 at 13:44 UTC
    ...rather than scrolling up and down in this ugly dos window?
    Have you changed the properties on your DOS window?

    Under later Windoze versions, you can change the window width and height (in characters), the buffer width and height, and make this permanent for every DOS window you open. The mouse wheel also works for scrolling.

    Do you know how to copy/paste? (Some of my co-workers find it frustrating that it's not ^C/^P.)

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

      Right click on the title bar, select Edit, then Mark. Use you mouse to select what you want, then hit the Enter key. You've just copied.

      Pasting is right-click on the title bar, select Mark, then Paste;

      Don
      WHITEPAGES.COM | INC
      Everything I've learned in life can be summed up in a small perl script!
        Yes, well, that's the old way. I wasn't asking for myself, but rather asking if the OP had trouble with that as well.

        My favored method is to turn on Quick Edit, mark a rectangle with the mouse, and hit Enter/Return to copy. The right (secondary) mouse button pastes in the DOS window, or Ctrl-V in a Windoze window.

        -QM
        --
        Quantum Mechanics: The dreams stuff is made of

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

    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.)

    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.

    the lowliest monk