Commit | Line | Data |
d73d8321 |
1 | # $Id: Name.pm,v 1.5 2004/08/18 17:53:45 xmath Exp $ |
16c23894 |
2 | |
3 | package Sub::Name; |
4 | |
5 | =head1 NAME |
6 | |
7 | Sub::Name - (re)name a sub |
8 | |
9 | =head1 SYNOPSIS |
10 | |
11 | use Sub::Name; |
12 | |
13 | subname $name, $subref; |
14 | |
15 | $subref = subname foo => sub { ... }; |
16 | |
17 | =head1 DESCRIPTION |
18 | |
d73d8321 |
19 | This module has only one function, which is also exported by default: |
16c23894 |
20 | |
21 | =head2 subname NAME, CODEREF |
22 | |
23 | Assigns a new name to referenced sub. If package specification is omitted in |
24 | the name, then the current package is used. The return value is the sub. |
25 | |
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 |
28 | to do glob-assignment yourself. |
29 | |
d73d8321 |
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 |
32 | can be very useful for debugging. |
16c23894 |
33 | |
34 | =head1 AUTHOR |
35 | |
36 | Matthijs van Duin <xmath@cpan.org> |
37 | |
38 | Copyright (C) 2004 Matthijs van Duin. All rights reserved. |
39 | This program is free software; you can redistribute it and/or modify |
40 | it under the same terms as Perl itself. |
41 | |
42 | =cut |
43 | |
44 | use 5.006; |
45 | |
46 | use strict; |
47 | use warnings; |
48 | |
d73d8321 |
49 | our $VERSION = '0.02'; |
16c23894 |
50 | |
51 | use base 'Exporter'; |
52 | use base 'DynaLoader'; |
53 | |
54 | our @EXPORT = qw(subname); |
55 | our @EXPORT_OK = @EXPORT; |
56 | |
57 | bootstrap Sub::Name $VERSION; |
58 | |
59 | 1; |