我需要知道我的函数是从哪个Perl文件调用的。假设我有一个模块(MyModule.pm
),它有以下函数:
package MyModule;
sub myFunc{
# Here I need to print the name of the file that the function was called from
}
脚本myScript.pl
使用MyModule
并调用函数myFunc()
:
use MyModule;
MyModule->myFunc();
我需要在此处调用myFunc()
以打印“myScript.pl
“
在Perl中有什么方法可以做到这一点吗?
1条答案
按热度按时间lztngnrs1#
在方法内部,
有关详细信息,请查看
perldoc -f caller
。