发现 Perl 模块拥有的所有子例程的最佳方法是什么?
以编程方式发现 Perl 模块具有的所有子例程的最佳方法是什么? 这可以是一个模块、一个类(无 @EXPORT)或介于两者之间的任何内容。
编辑:下面的所有方法看起来都有效。 我可能会在生产中使用 Class::Sniff 或 Class::Inspector 。 然而,Leon 的答案被标记为“已接受”,因为它回答了所提出的问题,尽管不需要使用严格的“refs”
。 :-) Class::Sniff 随着它的进展可能是一个不错的选择; 看来是花了很多心思的。
What's the best way to programatically discover all of the subroutines a perl module has? This could be a module, a class (no @EXPORT), or anything in-between.
Edit: All of the methods below look like they will work. I'd probably use the Class::Sniff or Class::Inspector in production. However, Leon's answer is marked as 'accepted' since it answers the question as posed, even though no strict 'refs'
has to be used. :-) Class::Sniff may be a good choice as it progresses; it looks like a lot of thought has gone into it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ETA:如果你想过滤掉导入的子程序,你可以这样做
ETA: if you want to filter out imported subroutines, you can do this
Class::Inspector:
Class::Inspector:
看看这个:
Class::Sniff
Have a look at this:
Class::Sniff