Filename | /usr/share/perl/5.28/subs.pm |
Statements | Executed 8 statements in 27µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 8µs | 8µs | import | subs::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package subs; | ||||
2 | |||||
3 | 1 | 300ns | our $VERSION = '1.03'; | ||
4 | |||||
5 | =head1 NAME | ||||
6 | |||||
7 | subs - Perl pragma to predeclare subroutine names | ||||
8 | |||||
9 | =head1 SYNOPSIS | ||||
10 | |||||
11 | use subs qw(frob); | ||||
12 | frob 3..10; | ||||
13 | |||||
14 | =head1 DESCRIPTION | ||||
15 | |||||
16 | This will predeclare all the subroutines whose names are | ||||
17 | in the list, allowing you to use them without parentheses (as list operators) | ||||
18 | even before they're declared. | ||||
19 | |||||
20 | Unlike pragmas that affect the C<$^H> hints variable, the C<use vars> and | ||||
21 | C<use subs> declarations are not lexically scoped to the block they appear | ||||
22 | in: they affect | ||||
23 | the entire package in which they appear. It is not possible to rescind these | ||||
24 | declarations with C<no vars> or C<no subs>. | ||||
25 | |||||
26 | See L<perlmodlib/Pragmatic Modules> and L<strict/strict subs>. | ||||
27 | |||||
28 | =cut | ||||
29 | |||||
30 | 1 | 13µs | require 5.000; | ||
31 | |||||
32 | # spent 8µs within subs::import which was called:
# once (8µs+0s) by Data::Dump::BEGIN@5 at line 5 of Data/Dump.pm | ||||
33 | 1 | 500ns | my $callpack = caller; | ||
34 | 1 | 200ns | my $pack = shift; | ||
35 | 1 | 600ns | my @imports = @_; | ||
36 | 1 | 5µs | foreach my $sym (@imports) { | ||
37 | 1 | 4µs | *{"${callpack}::$sym"} = \&{"${callpack}::$sym"}; | ||
38 | } | ||||
39 | }; | ||||
40 | |||||
41 | 1 | 3µs | 1; |