Commit | Line | Data |
16c23894 |
1 | package Sub::Name; |
21b37dd9 |
2 | # ABSTRACT: (Re)name a sub |
1002e78c |
3 | # KEYWORDS: subroutine function utility name rename symbol |
16c23894 |
4 | |
54595ea8 |
5 | =pod |
16c23894 |
6 | |
7 | =head1 SYNOPSIS |
8 | |
9 | use Sub::Name; |
10 | |
11 | subname $name, $subref; |
12 | |
13 | $subref = subname foo => sub { ... }; |
14 | |
15 | =head1 DESCRIPTION |
16 | |
d73d8321 |
17 | This module has only one function, which is also exported by default: |
16c23894 |
18 | |
30f18ad8 |
19 | =for stopwords subname |
20 | |
16c23894 |
21 | =head2 subname NAME, CODEREF |
22 | |
a0f015f5 |
23 | Assigns a new name to referenced sub. If package specification is omitted in |
16c23894 |
24 | the name, then the current package is used. The return value is the sub. |
25 | |
a0f015f5 |
26 | The name is only used for informative routines (caller, Carp, etc). You won't |
27 | be able to actually invoke the sub by the given name. To allow that, you need |
16c23894 |
28 | to do glob-assignment yourself. |
29 | |
a0f015f5 |
30 | Note that for anonymous closures (subs that reference lexicals declared outside |
31 | the sub itself) you can name each instance of the closure differently, which |
d73d8321 |
32 | can be very useful for debugging. |
16c23894 |
33 | |
fa1e9525 |
34 | =head1 SEE ALSO |
35 | |
691b40bc |
36 | =for :list |
37 | * L<Sub::Identify> - for getting information about subs |
86f08d91 |
38 | * L<Sub::Util> - set_subname is another implementation of C<subname> |
fa1e9525 |
39 | |
30f18ad8 |
40 | =for stopwords cPanel |
41 | |
d2e2a4b9 |
42 | =head1 COPYRIGHT AND LICENSE |
43 | |
54595ea8 |
44 | This software is copyright (c) 2004, 2008 by Matthijs van Duin, all rights reserved; |
45 | copyright (c) 2014 cPanel Inc., all rights reserved. |
16c23894 |
46 | |
a0f015f5 |
47 | This program is free software; you can redistribute it and/or modify |
16c23894 |
48 | it under the same terms as Perl itself. |
49 | |
50 | =cut |
51 | |
52 | use 5.006; |
53 | |
54 | use strict; |
55 | use warnings; |
56 | |
9c9043ec |
57 | our $VERSION = '0.22'; |
dfd7ef25 |
58 | |
3ae12aec |
59 | use Exporter (); |
60 | *import = \&Exporter::import; |
16c23894 |
61 | |
62 | our @EXPORT = qw(subname); |
63 | our @EXPORT_OK = @EXPORT; |
64 | |
54595ea8 |
65 | use XSLoader; |
66 | XSLoader::load( |
67 | __PACKAGE__, |
dfd7ef25 |
68 | $VERSION, |
54595ea8 |
69 | ); |
16c23894 |
70 | |
71 | 1; |