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];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With