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

How do I automatically run "c" in the debugger?

I have a script which runs under the debugger (perl -d) and sets up a debugging env for me to play with interractively. Currently I run the program (./dbg) then type 'c' in the debugger to have it execute, leaving objects to play with. I'm sure there's some way to to this automatically but I couldn't find it.

This seemed promising, but I could get interaction back:

BEGIN { parse_options("NonStop=1"); }
Thanks,

Brad
The script concerned (not really relevent):

#!/usr/bin/perl -dw use lib './lib'; use MY::DBI; {no warnings 'once'; $p = MY::Patient->retrieve(1); $u = MY::User->retrieve(1); }

Replies are listed 'Best First'.
Soln: Automatically "continue" script under the debugger
by bsb (Priest) on Jun 27, 2003 at 10:22 UTC
    I worked it out, just switch back to stopping at the end:
    #!/usr/bin/perl -w BEGIN { DB::parse_options("NonStop=1"); } # script here $a = [1,2,3]; DB::parse_options("NonStop=0");
    There are probably neater ways though.

    Demo:

Re: Automatically "continue" script under the debugger
by BrowserUk (Patriarch) on Jun 27, 2003 at 09:38 UTC

    It's not entirely clear to me if this is the answer to your question, but I think that you may want to look into the use of the envirnment variable PERLDB_OPTS and or the use of an rc file: Quoting from perldebug

    The debugger has numerous options settable using the o command, either interactively or from the environment or an rc file. (./.perldb or ~/.perldb under Unix.)

    Is that what you wanted?


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


      Not quite. There doesn't seem to be an option to run the script at the start.

      I didn't know you could have a per-directory .perldb file. I was using the DB::parseoption sub instead. (I forgot the DB:: in my original post)

      With NonStop the script would load the debugger, run the script and exit (instead of dropping back to the debugger).

      I tried kill INT, $$; at the end of the script, to no avail: