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