开发者

Perl: Determining where a function is defined [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:

In Perl, how can I check from which module a given function was imported?

Hi guys! I am using my weekend time to comb through our web app to get a better understanding of it. It uses numerous modules whose functions get pulled into it and my question is this.. how can I determine the module where a function originates?

Reason I ask is because I am using print STDERR lines sprinkled here and there to understand the way data moves around (it has demystified things greatly).. here's an example....

 ($file_data,$count) = lookup_files($customer,$site,'','0',$d);

What I'm not sure of is where lookup_files() is originating from. What I'd like to see is this....

 ($file_data,$count) = lookup_files($customer,$site,'','0',$d);
 print STDERR "lookup_f开发者_如何学编程iles originates here " . <CODE TO SHOW ME WHERE lookup_files IS DEFINED>;

Any advice on where to begin would be greatly appreciated. The webapp uses tons of use modules and instead of selectively importing only what's needed, each use seems to bring all functions in.

I know my terminology might be incorrect when referring to "method", "parent" and so on in regards to Perl. If anyone would like to correct me on it that would be appreciated too. I am at best a beginner with this stuff. Janie


Take a look at the core module Devel::Peek

http://perldoc.perl.org/Devel/Peek.html#A-reference-to-a-subroutine

The output of that module's functions will tell you where a subroutine comes from


One fairly easy way is to load Carp::Always. If it’s a web app, you’ll need to put it in the code. For a command line you can just perl -MCarp::Always ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜