Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Sub/Name.pm |
Statements | Executed 15 statements in 335µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 937µs | 1.10ms | BEGIN@49 | Sub::Name::
1 | 1 | 1 | 33µs | 33µs | BEGIN@42 | Sub::Name::
1 | 1 | 1 | 23µs | 23µs | bootstrap (xsub) | Sub::Name::
1 | 1 | 1 | 12µs | 17µs | BEGIN@44 | Sub::Name::
1 | 1 | 1 | 11µs | 2.50ms | BEGIN@50 | Sub::Name::
1 | 1 | 1 | 10µs | 18µs | BEGIN@45 | Sub::Name::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Sub::Name; | ||||
2 | |||||
3 | =head1 NAME | ||||
4 | |||||
5 | Sub::Name - (re)name a sub | ||||
6 | |||||
7 | =head1 SYNOPSIS | ||||
8 | |||||
9 | use Sub::Name; | ||||
10 | |||||
11 | subname $name, $subref; | ||||
12 | |||||
13 | $subref = subname foo => sub { ... }; | ||||
14 | |||||
15 | =head1 DESCRIPTION | ||||
16 | |||||
17 | This module has only one function, which is also exported by default: | ||||
18 | |||||
19 | =head2 subname NAME, CODEREF | ||||
20 | |||||
21 | Assigns a new name to referenced sub. If package specification is omitted in | ||||
22 | the name, then the current package is used. The return value is the sub. | ||||
23 | |||||
24 | The name is only used for informative routines (caller, Carp, etc). You won't | ||||
25 | be able to actually invoke the sub by the given name. To allow that, you need | ||||
26 | to do glob-assignment yourself. | ||||
27 | |||||
28 | Note that for anonymous closures (subs that reference lexicals declared outside | ||||
29 | the sub itself) you can name each instance of the closure differently, which | ||||
30 | can be very useful for debugging. | ||||
31 | |||||
32 | =head1 AUTHOR | ||||
33 | |||||
34 | Matthijs van Duin <xmath@cpan.org> | ||||
35 | |||||
36 | Copyright (C) 2004, 2008 Matthijs van Duin. All rights reserved. | ||||
37 | This program is free software; you can redistribute it and/or modify | ||||
38 | it under the same terms as Perl itself. | ||||
39 | |||||
40 | =cut | ||||
41 | |||||
42 | 2 | 53µs | 1 | 33µs | # spent 33µs within Sub::Name::BEGIN@42 which was called:
# once (33µs+0s) by namespace::clean::BEGIN@14 at line 42 # spent 33µs making 1 call to Sub::Name::BEGIN@42 |
43 | |||||
44 | 2 | 24µs | 2 | 22µs | # spent 17µs (12+5) within Sub::Name::BEGIN@44 which was called:
# once (12µs+5µs) by namespace::clean::BEGIN@14 at line 44 # spent 17µs making 1 call to Sub::Name::BEGIN@44
# spent 5µs making 1 call to strict::import |
45 | 2 | 32µs | 2 | 27µs | # spent 18µs (10+9) within Sub::Name::BEGIN@45 which was called:
# once (10µs+9µs) by namespace::clean::BEGIN@14 at line 45 # spent 18µs making 1 call to Sub::Name::BEGIN@45
# spent 8µs making 1 call to warnings::import |
46 | |||||
47 | 1 | 1µs | our $VERSION = '0.05'; | ||
48 | |||||
49 | 2 | 161µs | 2 | 1.18ms | # spent 1.10ms (937µs+164µs) within Sub::Name::BEGIN@49 which was called:
# once (937µs+164µs) by namespace::clean::BEGIN@14 at line 49 # spent 1.10ms making 1 call to Sub::Name::BEGIN@49
# spent 77µs making 1 call to base::import |
50 | 2 | 50µs | 2 | 4.99ms | # spent 2.50ms (11µs+2.49) within Sub::Name::BEGIN@50 which was called:
# once (11µs+2.49ms) by namespace::clean::BEGIN@14 at line 50 # spent 2.50ms making 1 call to Sub::Name::BEGIN@50
# spent 2.49ms making 1 call to base::import |
51 | |||||
52 | 1 | 2µs | our @EXPORT = qw(subname); | ||
53 | 1 | 1µs | our @EXPORT_OK = @EXPORT; | ||
54 | |||||
55 | 1 | 7µs | 1 | 304µs | bootstrap Sub::Name $VERSION; # spent 304µs making 1 call to DynaLoader::bootstrap |
56 | |||||
57 | 1 | 5µs | 1; | ||
# spent 23µs within Sub::Name::bootstrap which was called:
# once (23µs+0s) by DynaLoader::bootstrap at line 219 of DynaLoader.pm |