File Coverage

blib/lib/Sub/Name.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 19 19 100.0


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