import Sub-Name 0.02 from CPAN
[p5sagit/Sub-Name.git] / lib / Sub / Name.pm
CommitLineData
d73d8321 1# $Id: Name.pm,v 1.5 2004/08/18 17:53:45 xmath Exp $
16c23894 2
3package Sub::Name;
4
5=head1 NAME
6
7Sub::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 19This module has only one function, which is also exported by default:
16c23894 20
21=head2 subname NAME, CODEREF
22
23Assigns a new name to referenced sub. If package specification is omitted in
24the name, then the current package is used. The return value is the sub.
25
26The name is only used for informative routines (caller, Carp, etc). You won't
27be able to actually invoke the sub by the given name. To allow that, you need
28to do glob-assignment yourself.
29
d73d8321 30Note that for anonymous closures (subs that reference lexicals declared outside
31the sub itself) you can name each instance of the closure differently, which
32can be very useful for debugging.
16c23894 33
34=head1 AUTHOR
35
36Matthijs van Duin <xmath@cpan.org>
37
38Copyright (C) 2004 Matthijs van Duin. All rights reserved.
39This program is free software; you can redistribute it and/or modify
40it under the same terms as Perl itself.
41
42=cut
43
44use 5.006;
45
46use strict;
47use warnings;
48
d73d8321 49our $VERSION = '0.02';
16c23894 50
51use base 'Exporter';
52use base 'DynaLoader';
53
54our @EXPORT = qw(subname);
55our @EXPORT_OK = @EXPORT;
56
57bootstrap Sub::Name $VERSION;
58
591;