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

I have a question running 'perl -d' for AUTOLOAD functions. In the perl debugger, if I do a 'S', it lists all the packages that has been loaded. I have a package named "Change.pm". If I call Change::sub1() and sub1 is not defined in Change.pm, the code looks into AUTOLOAD, and load up another package called "ChangeMore.pm" and look for the sub1() in there instead. How can I put a breakpoint inside sub1() when it is called in ChangeMore.pm? I only see all the subs in Change.pm when I do an 'S', I tried 'b postpone ChangeMore::sub1' and that didn't work.. TIA

Replies are listed 'Best First'.
Re: debugging autoload
by tilly (Archbishop) on Jan 12, 2009 at 23:08 UTC
    In the debugger do your own use ChangeMore; and then you should find its methods with S.

    Alternately set a breakpoint inside of AUTOLOAD, then set the breakpoint you need after it has loaded the package it needs. You will have to take this approach if, for instance, the module is using AutoLoader to dynamically load the subroutine.

      That did it!! The package was loaded dynamically, but was able to do 1) 'Use ChangeMore' in debugger 2) 'b postpone ChangeMore::sub1' 3) c to run to the beginning of sub1() Thanks a bunch!!