Perl:确定函数的定义位置

发布于 2024-10-12 07:56:24 字数 878 浏览 2 评论 0原文

可能的重复:
在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

述情 2024-10-19 07:56:24

看一下核心模块 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

说好的呢 2024-10-19 07:56:24

一种相当简单的方法是加载 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 ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文