开发者

How can I tell which subroutine I'm in?

Is there a way to get the name of the enclosing subroutine of a piece of perl code? For example:

sub foo 开发者_开发技巧{ print where_am_i(); }

will output 'foo'.


Use the caller function:

my $function = (caller(0))[3];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜