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

Hi, I have used a module like this,
use module 'load';

so it goes and calls import function in load.pm while loading module. But when I execute my script with -d option to debug. Its not going to import function and all. I would want to debug that part of my code. what is option to make the debugger to start from there. Could any one help me on this?

Replies are listed 'Best First'.
Re: Debug import function code
by ikegami (Patriarch) on Sep 02, 2011 at 10:34 UTC

    What happens if you set a breakpoint in your module's import?

    If that doesn't work, you could do module->import('load'); in the debugger. Or comment it out and do require module; module->import('load'); in the debugger.

      Actually when I executing the script with -d option its exiting somewhere in the middle of import code. Thats the reason i would want to debug import code. Any way to do this?

        Add $DB::single = 1 to the import routine. That should make the debugger break at that location.


        "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

Re: Debug import function code
by pemungkah (Priest) on Sep 02, 2011 at 20:05 UTC
    This is a trick that will work.
    perl -d yourscript [debugger starts> b Your::Module::import R
    That will restart the debugger with all your breakpoints intact - resulting in a stop inside your import method. Even works for BEGIN blocks.