sub_util_subname#
Return the fully qualified name of a subroutine reference.
Synopsis#
use Sub::Util qw(subname);
my $name = subname \&some_sub; # 'Pkg::some_sub'
my $name = subname sub { 1 }; # 'main::__ANON__'
What you get back#
A string of the form "Package::name". Anonymous subroutines
produce "Package::__ANON__". If the subroutine has been renamed
with set_subname, the new name is returned. Passing something
that is not a code reference croaks with
Not a subroutine reference.
Examples#
package My::Pkg;
sub hello { 1 }
print Sub::Util::subname(\&hello); # 'My::Pkg::hello'
Differences from upstream#
Fully compatible with upstream.
See also#
set_subname— rename a code reference (useful for stack traces).