Commit | Line | Data |
16c23894 |
1 | package Sub::Name; |
2 | |
3 | =head1 NAME |
4 | |
5 | Sub::Name - (re)name a sub |
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 | |
19 | =head2 subname NAME, CODEREF |
20 | |
a0f015f5 |
21 | Assigns a new name to referenced sub. If package specification is omitted in |
16c23894 |
22 | the name, then the current package is used. The return value is the sub. |
23 | |
a0f015f5 |
24 | The name is only used for informative routines (caller, Carp, etc). You won't |
25 | be able to actually invoke the sub by the given name. To allow that, you need |
16c23894 |
26 | to do glob-assignment yourself. |
27 | |
a0f015f5 |
28 | Note that for anonymous closures (subs that reference lexicals declared outside |
29 | the sub itself) you can name each instance of the closure differently, which |
d73d8321 |
30 | can be very useful for debugging. |
16c23894 |
31 | |
fa1e9525 |
32 | =head1 SEE ALSO |
33 | |
34 | =over 4 |
35 | |
36 | =item * |
37 | L<Sub::Identify> - for getting information about subs |
38 | |
39 | =back |
40 | |
16c23894 |
41 | =head1 AUTHOR |
42 | |
43 | Matthijs van Duin <xmath@cpan.org> |
44 | |
979516cc |
45 | Copyright (C) 2004, 2008 Matthijs van Duin. All rights reserved. |
24f50a79 |
46 | Copyright (C) 2014 cPanel Inc. All rights reserved. |
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 | |
dc237631 |
57 | our $VERSION = '0.08'; |
16c23894 |
58 | |
59 | use base 'Exporter'; |
60 | use base 'DynaLoader'; |
61 | |
62 | our @EXPORT = qw(subname); |
63 | our @EXPORT_OK = @EXPORT; |
64 | |
65 | bootstrap Sub::Name $VERSION; |
66 | |
67 | 1; |