in reply to Re: perl -d at runtime?
in thread perl -d at runtime?

So there's no way within Perl?

(Just curiousity, not stubbornness)

Replies are listed 'Best First'.
Re: Re: Re: perl -d at runtime?
by davido (Cardinal) on Dec 19, 2003 at 05:18 UTC
    I researched your question twice -- once when I posted my initial reply, and again to double-check myself in response to your followup requesting another way.

    I am going out on a limb here, because even though I've researched it a bit, it's always dangerous to say, "No, there's no other way." Rather than to say that, I'll mention my gut feeling after having re-read perldebug, perldebtut and perlrun.

    What I kind of picked up on in perldebug was this line:

    ...the -d flag tells the compiler to insert source information into the parse trees it's about to hand off to the interpreter.

    So we can first understand that without the -d flag, the compiler doesn't insert into the parse trees the source info necessary to implement the debugger. That means that the script must at least be invoked with the -d flag so that the compiletime work is done that will enable the debugger to work.

    Now that we know that the -d flag must be present, the only question is, is there a way to invoke the debugger at compiletime but not have the interpreter invoke it except on demand? Re-reading perldebug and perlrun, I just don't see a way of doing that. But I'm definately not a debugger expert, and it's possible that someone more familiar with using the debugger will know what the trick is. My intuition is that there isn't a pure-Perl solution to your need though.

    However, all may not be lost. Look at the Devel:: heirarchy on CPAN. There is a wide range of development tools there, and some allow for runtime control. You haven't told us what it is that you need from the debugger, but I'm just suggesting that maybe you can satisfy the need with a tool other than the debugger; perhaps a Devel:: module.

    I hope this helps. I've done more reading on the subject than I initially intended to, but it was an interesting question.


    Dave

      Thanks for taking the time to write up such a thorough reply.

      I suspected that there may be no way in perl but was hoping that a guru might pop up and say something like:

      BEGIN { use DB; DB::__initdebugger() }
      or alternatively, respond with an authoritative "No".

      Some variant of your first response would suit my need, although for now I'll just continue using "perl -d ./script.pl" or "make testdb" when required. I really am just curious. The least I can do in response to your effort is provide you the context that provoked the question:

      You haven't told us what it is that you need from the debugger
      I actually want to use it interactively. While writing a module, I'm also writing a companion script that sets up a few objects and conditionally runs tests on them and/or leaves me at the debugging prompt. Then I can play around, debug, try things, interactively write new tests, etc. Nothing special

        The monastery has no gurus, but all the gurus are currently out to lunch :) I suggest you give it a few days and then take your question to the people who created the debugger, the p5p.
Re: Re: Re: perl -d at runtime?
by Anonymous Monk on Dec 19, 2003 at 04:11 UTC
    If davido knew of a different way, he would've suggested it. His way is doing it within perl.