Filename | /usr/share/perl/5.10/Module/Load.pm |
Statements | Executed 18 statements in 486µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 17µs | 21µs | BEGIN@5 | Module::Load::
1 | 1 | 1 | 15µs | 20µs | import | Module::Load::
1 | 1 | 1 | 10µs | 34µs | BEGIN@11 | Module::Load::
1 | 1 | 1 | 10µs | 27µs | BEGIN@37 | Module::Load::
1 | 1 | 1 | 6µs | 6µs | BEGIN@6 | Module::Load::
1 | 1 | 1 | 4µs | 4µs | _who | Module::Load::
0 | 0 | 0 | 0s | 0s | _is_file | Module::Load::
0 | 0 | 0 | 0s | 0s | _to_file | Module::Load::
0 | 0 | 0 | 0s | 0s | load | Module::Load::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Module::Load; | ||||
2 | |||||
3 | 1 | 700ns | $VERSION = '0.16'; | ||
4 | |||||
5 | 3 | 29µs | 2 | 25µs | # spent 21µs (17+4) within Module::Load::BEGIN@5 which was called:
# once (17µs+4µs) by Module::Load::Conditional::BEGIN@5 at line 5 # spent 21µs making 1 call to Module::Load::BEGIN@5
# spent 4µs making 1 call to strict::import |
6 | 3 | 52µs | 1 | 6µs | # spent 6µs within Module::Load::BEGIN@6 which was called:
# once (6µs+0s) by Module::Load::Conditional::BEGIN@5 at line 6 # spent 6µs making 1 call to Module::Load::BEGIN@6 |
7 | |||||
8 | # spent 20µs (15+4) within Module::Load::import which was called:
# once (15µs+4µs) by Module::Load::Conditional::BEGIN@5 at line 5 of Module/Load/Conditional.pm | ||||
9 | 3 | 11µs | 1 | 4µs | my $who = _who(); # spent 4µs making 1 call to Module::Load::_who |
10 | |||||
11 | 3 | 147µs | 2 | 58µs | # spent 34µs (10+24) within Module::Load::BEGIN@11 which was called:
# once (10µs+24µs) by Module::Load::Conditional::BEGIN@5 at line 11 # spent 34µs making 1 call to Module::Load::BEGIN@11
# spent 24µs making 1 call to strict::unimport |
12 | *{"${who}::load"} = *load; | ||||
13 | } | ||||
14 | } | ||||
15 | |||||
16 | sub load (*;@) { | ||||
17 | my $mod = shift or return; | ||||
18 | my $who = _who(); | ||||
19 | |||||
20 | if( _is_file( $mod ) ) { | ||||
21 | require $mod; | ||||
22 | } else { | ||||
23 | LOAD: { | ||||
24 | my $err; | ||||
25 | for my $flag ( qw[1 0] ) { | ||||
26 | my $file = _to_file( $mod, $flag); | ||||
27 | eval { require $file }; | ||||
28 | $@ ? $err .= $@ : last LOAD; | ||||
29 | } | ||||
30 | die $err if $err; | ||||
31 | } | ||||
32 | } | ||||
33 | |||||
34 | ### This addresses #41883: Module::Load cannot import | ||||
35 | ### non-Exporter module. ->import() routines weren't | ||||
36 | ### properly called when load() was used. | ||||
37 | 3 | 233µs | 2 | 43µs | # spent 27µs (10+17) within Module::Load::BEGIN@37 which was called:
# once (10µs+17µs) by Module::Load::Conditional::BEGIN@5 at line 37 # spent 27µs making 1 call to Module::Load::BEGIN@37
# spent 17µs making 1 call to strict::unimport |
38 | my $import; | ||||
39 | if (@_ and $import = $mod->can('import')) { | ||||
40 | unshift @_, $mod; | ||||
41 | goto &$import; | ||||
42 | } | ||||
43 | } | ||||
44 | } | ||||
45 | |||||
46 | sub _to_file{ | ||||
47 | local $_ = shift; | ||||
48 | my $pm = shift || ''; | ||||
49 | |||||
50 | my @parts = split /::/; | ||||
51 | |||||
52 | ### because of [perl #19213], see caveats ### | ||||
53 | my $file = $^O eq 'MSWin32' | ||||
54 | ? join "/", @parts | ||||
55 | : File::Spec->catfile( @parts ); | ||||
56 | |||||
57 | $file .= '.pm' if $pm; | ||||
58 | |||||
59 | ### on perl's before 5.10 (5.9.5@31746) if you require | ||||
60 | ### a file in VMS format, it's stored in %INC in VMS | ||||
61 | ### format. Therefor, better unixify it first | ||||
62 | ### Patch in reply to John Malmbergs patch (as mentioned | ||||
63 | ### above) on p5p Tue 21 Aug 2007 04:55:07 | ||||
64 | $file = VMS::Filespec::unixify($file) if $^O eq 'VMS'; | ||||
65 | |||||
66 | return $file; | ||||
67 | } | ||||
68 | |||||
69 | 1 | 9µs | # spent 4µs within Module::Load::_who which was called:
# once (4µs+0s) by Module::Load::import at line 9 | ||
70 | |||||
71 | sub _is_file { | ||||
72 | local $_ = shift; | ||||
73 | return /^\./ ? 1 : | ||||
74 | /[^\w:']/ ? 1 : | ||||
75 | undef | ||||
76 | #' silly bbedit.. | ||||
77 | } | ||||
78 | |||||
79 | |||||
80 | 1 | 3µs | 1; | ||
81 | |||||
82 | __END__ |