在Perl中,我们可以获取当前包的名称和当前行号使用预定义的变量,如__PACKAGE__和__LINE__.
__PACKAGE__
__LINE__
像这样我想得到当前子程序的名称:
use strict; use warnings; print __PACKAGE__; sub test() { print __LINE__; } &test();
在上面的代码中,我想获得函数内部子程序的名称test.
test
perl
perl ×1