Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Debug import function code

by Anonymous Monk
on Sep 02, 2011 at 10:21 UTC ( [id://923817]=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://923817]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-03-28 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found