1 # $Id: Name.pm,v 1.5 2004/08/18 17:53:45 xmath Exp $
7 Sub::Name - (re)name a sub
13 subname $name, $subref;
15 $subref = subname foo => sub { ... };
19 This module has only one function, which is also exported by default:
21 =head2 subname NAME, CODEREF
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.
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.
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.
36 Matthijs van Duin <xmath@cpan.org>
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.
49 our $VERSION = '0.02';
52 use base 'DynaLoader';
54 our @EXPORT = qw(subname);
55 our @EXPORT_OK = @EXPORT;
57 bootstrap Sub::Name $VERSION;