Perl:确定函数的定义位置
大家好! 我利用周末时间梳理我们的网络应用程序,以更好地了解它。它使用了许多模块,这些模块的函数被拉入其中,我的问题是......我如何确定函数源自的模块?
我问的原因是因为我使用打印 STDERR 行散布在这里和那里来理解数据移动的方式(它极大地揭开了事物的神秘面纱)..这是一个例子....
($file_data,$count) = lookup_files($customer,$site,'','0',$d);
我不确定的是哪里Lookup_files() 源自。我想看到的是......
($file_data,$count) = lookup_files($customer,$site,'','0',$d);
print STDERR "lookup_files originates here " . <CODE TO SHOW ME WHERE lookup_files IS DEFINED>;
任何关于从哪里开始的建议将不胜感激。该网络应用程序使用了大量的使用模块,并且每次使用似乎都引入了所有功能,而不是选择性地仅导入所需的模块。
我知道在涉及 Perl 的“方法”、“父级”等时,我的术语可能不正确。如果有人愿意纠正我,我也将不胜感激。我充其量只是这个东西的初学者。珍妮
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_files 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下核心模块 Devel::Peek
http: //perldoc.perl.org/Devel/Peek.html#A-reference-to-a-subroutine
该模块函数的输出将告诉您子例程来自哪里
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
一种相当简单的方法是加载 Carp::Always。如果它是网络应用程序,您需要将其放入代码中。对于命令行,您只需
perl -MCarp::Always ...
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 ...