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


In reply to Re: Re: Re: perl -d at runtime? by davido
in thread perl -d at runtime? by bsb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.