Commit | Line | Data |
16c23894 |
1 | NAME |
2 | Sub::Name - (re)name a sub |
3 | |
4 | SYNOPSIS |
5 | use Sub::Name; |
6 | |
7 | subname $name, $subref; |
8 | |
9 | $subref = subname foo => sub { ... }; |
10 | |
11 | DESCRIPTION |
d73d8321 |
12 | This module has only one function, which is also exported by default: |
16c23894 |
13 | |
14 | subname NAME, CODEREF |
15 | Assigns a new name to referenced sub. If package specification is |
16 | omitted in the name, then the current package is used. The return value |
17 | is the sub. |
18 | |
19 | The name is only used for informative routines (caller, Carp, etc). You |
20 | won't be able to actually invoke the sub by the given name. To allow |
21 | that, you need to do glob-assignment yourself. |
22 | |
d73d8321 |
23 | Note that for anonymous closures (subs that reference lexicals declared |
24 | outside the sub itself) you can name each instance of the closure |
25 | differently, which can be very useful for debugging. |
16c23894 |
26 | |
27 | AUTHOR |
28 | Matthijs van Duin <xmath@cpan.org> |
29 | |
24f50a79 |
30 | Copyright (C) 2004, 2008 Matthijs van Duin. All rights reserved. |
31 | Copyright (C) 2014 cPanel Inc. All rights reserved. This program is free |
32 | software; you can redistribute it and/or modify it under the same terms |
33 | as Perl itself. |
34 | |