Filename | /usr/share/perl/5.10/Module/Load.pm |
Statements | Executed 18 statements in 480µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 20µs | 25µs | BEGIN@5 | Module::Load::
1 | 1 | 1 | 15µs | 19µs | import | Module::Load::
1 | 1 | 1 | 10µs | 23µs | BEGIN@37 | Module::Load::
1 | 1 | 1 | 9µs | 30µs | BEGIN@11 | Module::Load::
1 | 1 | 1 | 4µs | 4µ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 | 28µs | 2 | 30µs | # spent 25µs (20+5) within Module::Load::BEGIN@5 which was called:
# once (20µs+5µs) by Module::Load::Conditional::BEGIN@5 at line 5 # spent 25µs making 1 call to Module::Load::BEGIN@5
# spent 5µs making 1 call to strict::import |
6 | 3 | 46µs | 1 | 4µs | # spent 4µs within Module::Load::BEGIN@6 which was called:
# once (4µs+0s) by Module::Load::Conditional::BEGIN@5 at line 6 # spent 4µs making 1 call to Module::Load::BEGIN@6 |
7 | |||||
8 | # spent 19µ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 | 151µs | 2 | 50µs | # spent 30µs (9+21) within Module::Load::BEGIN@11 which was called:
# once (9µs+21µs) by Module::Load::Conditional::BEGIN@5 at line 11 # spent 30µs making 1 call to Module::Load::BEGIN@11
# spent 21µ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 | 230µs | 2 | 36µs | # spent 23µs (10+13) within Module::Load::BEGIN@37 which was called:
# once (10µs+13µs) by Module::Load::Conditional::BEGIN@5 at line 37 # spent 23µs making 1 call to Module::Load::BEGIN@37
# spent 13µ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 | 10µ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__ |