Sub::Identify(3)
π NAME
Sub::Identify β Retrieve names of code references. Yes bestie, this is the Sub::Identify(3) page, and itβs literally here to help you figure out what a code reference is actually named. β¨
πΈ SYNOPSIS
use Sub::Identify ':all';
my $subname = sub_name( $some_coderef );
my $packagename = stash_name( $some_coderef );
# or, to get all at once...
my $fully_qualified_name = sub_fullname( $some_coderef );
defined $subname
and say "this coderef points to sub $subname in package $packagename";
my ($file, $line) = get_code_location( $some_coderef );
$file
and say "this coderef is defined at line $line in file $file";
is_sub_constant( $some_coderef )
and say "this coderef points to a constant subroutine";
π¦ DESCRIPTION
Okay so Sub::Identify lets you retrieve the real name of code references. Slay. It gives you six functions, and every single one of them takes a code reference. π
sub_nameβ returns the name of the code reference you passed in, or__ANON__if itβs an anonymous code reference.stash_nameβ returns its package.sub_fullnameβ returns the concatenation of the two, aka name plus package. Iconic.get_code_infoβ returns a list of two elements: the package and the subroutine name. Use this when you want both and youβre worried about speed.get_code_locationβ returns a two-element list containing the file name and the line number where the subroutine has been defined.is_sub_constantβ returns a boolean value indicating whether the subroutine is a constant or not.
π«Ά Caveat bestie: in case of subroutine aliasing, those functions always return the original name. No cap.
π§ Pure-Perl version
By default, Sub::Identify tries to load an XS implementation of the get_code_info, get_code_location and (on perl versions 5.16.0 and later) is_sub_constant functions, for speed. Fast fast. If that fails, or if the environment variable PERL_SUB_IDENTIFY_PP is defined to a true value, it will fall back to a pure perl implementation, that uses perlβs introspection mechanism, provided by the B module. Itβs giving backup plan, and honestly? Obsessed. π¦
π₯ SEE ALSO
Sub::Util, part of the module distributionScalar::List::Utilssince version1.40. Since this will be a core module starting with perl5.22.0, it is encouraged to migrate toSub::Utilwhen possible. iykyk.Sub::Name
π¦ SOURCE
A git repository for the sources is at <https://github.com/rgs/Sub-Identify>. Go look, bestie. β¨
π LICENSE
(c) Rafael Garcia-Suarez (rgs at consttype dot org) 2005, 2008, 2012, 2014, 2015
This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. Periodt. π
Okay thatβs the whole page, bestie β this oneβs from perl v5.42.0, dated 2017-04-12, and it ate. Mwah! ππ
π¦ where this page comes from
- opensuse-leap 16.0: perl-Sub-Identify 0.14-160000.2.2 Β· Artistic-1.0 or GPL-1.0+
- opensuse-leap 16.0: perl-Sub-Identify 0.14-160000.2.2 Β· Artistic-1.0 or GPL-1.0+
- opensuse-leap 16.0: perl-Sub-Identify 0.14-160000.2.2 Β· Artistic-1.0 or GPL-1.0+
- opensuse-leap 16.0: perl-Sub-Identify 0.14-160000.2.2 Β· Artistic-1.0 or GPL-1.0+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms