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

Hey fellow Perl users,

I'm writing a debugging module, and I was wondering what the best way to hook into Perl's use statement would be. It seems that DB::DB doesn't get run during compilation, so I can't detect it using that. Basically, I'd like to print the module being loaded and the filename loading it every time a use or require is encountered.

Thanks, Rob

Replies are listed 'Best First'.
Re: Perl debugger: Catching use statements
by hexcoder (Deacon) on Jun 18, 2010 at 22:09 UTC
Re: Perl debugger: Catching use statements
by repellent (Priest) on Jun 18, 2010 at 22:34 UTC
Re: Perl debugger: Catching use statements
by almut (Canon) on Jun 18, 2010 at 21:56 UTC

    What exactly is the idea?  Do you want to have this operating in the debugger (something like having a breakpoint at every use/require), or do you just want to know the list of modules which have been loaded in the end, together with their paths?

    In case of the latter, you could maybe just inspect %INC.

    Personally, I also like strace -efile ... for similar purposes, because it not only tells me the paths where the modules have been loaded from (including the .so files, in case of XS modules), but also all the paths that had been tried, etc.