sub_util_subname#
Return the fully qualified name of a subroutine reference.
תקציר#
use Sub::Util qw(subname);
my $name = subname \&some_sub; # 'Pkg::some_sub'
my $name = subname sub { 1 }; # 'main::__ANON__'
מה מוחזר#
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.
דוגמאות#
package My::Pkg;
sub hello { 1 }
print Sub::Util::subname(\&hello); # 'My::Pkg::hello'
הבדלים מן ה-upstream#
Fully compatible with upstream.
ראו גם#
set_subname- rename a code reference (useful for stack traces).