1Sub::Identify(3) User Contributed Perl Documentation Sub::Identify(3)
2
3
4
6 Sub::Identify - Retrieve names of code references
7
9 use Sub::Identify ':all';
10 my $subname = sub_name( $some_coderef );
11 my $p = stash_name( $some_coderef );
12 my $fully_qualified_name = sub_fullname( $some_coderef );
13 defined $subname
14 and print "this coderef points to sub $subname in package $p\n";
15
17 "Sub::Identify" allows you to retrieve the real name of code refer‐
18 ences. For this, it uses perl's introspection mechanism, provided by
19 the "B" module.
20
21 It provides four functions : "sub_name" returns the name of the subrou‐
22 tine (or "__ANON__" if it's an anonymous code reference), "stash_name"
23 returns its package, and "sub_fullname" returns the concatenation of
24 the two.
25
26 The fourth function, "get_code_info", returns a list of two elements,
27 the package and the subroutine name (in case of you want both and are
28 worried by the speed.)
29
30 In case of subroutine aliasing, those functions always return the orig‐
31 inal name.
32
34 (c) Rafael Garcia-Suarez (rgarciasuarez at gmail dot com) 2005, 2008
35
36 This program is free software; you may redistribute it and/or modify it
37 under the same terms as Perl itself.
38
39
40
41perl v5.8.8 2008-05-19 Sub::Identify(3)