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).