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];
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];
精彩评论