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