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
18 references. For this, it uses perl's introspection mechanism, provided
19 by the "B" module.
20
21 It provides four functions : "sub_name" returns the name of the
22 subroutine (or "__ANON__" if it's an anonymous code reference),
23 "stash_name" returns its package, and "sub_fullname" returns the
24 concatenation of 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
31 original 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.12.0 2008-12-09 Sub::Identify(3)