| Filename | /usr/share/perl/5.36/Module/Load.pm |
| Statements | Executed 24 statements in 606µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 9µs | 18µs | Module::Load::import |
| 1 | 1 | 1 | 7µs | 8µs | Module::Load::BEGIN@3 |
| 1 | 1 | 1 | 5µs | 8µs | Module::Load::BEGIN@89 |
| 1 | 1 | 1 | 4µs | 8µs | Module::Load::BEGIN@14 |
| 1 | 1 | 1 | 4µs | 9µs | Module::Load::_who |
| 1 | 1 | 1 | 3µs | 17µs | Module::Load::BEGIN@4 |
| 1 | 1 | 1 | 2µs | 2µs | Module::Load::BEGIN@5 |
| 0 | 0 | 0 | 0s | 0s | Module::Load::_is_file |
| 0 | 0 | 0 | 0s | 0s | Module::Load::_load |
| 0 | 0 | 0 | 0s | 0s | Module::Load::_to_file |
| 0 | 0 | 0 | 0s | 0s | Module::Load::autoload |
| 0 | 0 | 0 | 0s | 0s | Module::Load::autoload_remote |
| 0 | 0 | 0 | 0s | 0s | Module::Load::load |
| 0 | 0 | 0 | 0s | 0s | Module::Load::load_remote |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Module::Load; | ||||
| 2 | |||||
| 3 | 2 | 15µs | 2 | 9µs | # spent 8µs (7+900ns) within Module::Load::BEGIN@3 which was called:
# once (7µs+900ns) by Module::Load::Conditional::BEGIN@5 at line 3 # spent 8µs making 1 call to Module::Load::BEGIN@3
# spent 900ns making 1 call to strict::import |
| 4 | 2 | 16µs | 2 | 31µs | # spent 17µs (3+14) within Module::Load::BEGIN@4 which was called:
# once (3µs+14µs) by Module::Load::Conditional::BEGIN@5 at line 4 # spent 17µs making 1 call to Module::Load::BEGIN@4
# spent 14µs making 1 call to warnings::import |
| 5 | 2 | 31µs | 1 | 2µs | # spent 2µs within Module::Load::BEGIN@5 which was called:
# once (2µs+0s) by Module::Load::Conditional::BEGIN@5 at line 5 # spent 2µs making 1 call to Module::Load::BEGIN@5 |
| 6 | |||||
| 7 | 1 | 200ns | our $VERSION = '0.36'; | ||
| 8 | |||||
| 9 | |||||
| 10 | # spent 18µs (9+9) within Module::Load::import which was called:
# once (9µs+9µs) by Module::Load::Conditional::BEGIN@5 at line 5 of Module/Load/Conditional.pm | ||||
| 11 | 1 | 600ns | 1 | 9µs | my $who = _who(); # spent 9µs making 1 call to Module::Load::_who |
| 12 | 2 | 200ns | my $h; shift; | ||
| 13 | |||||
| 14 | 3 | 290µs | 2 | 12µs | # spent 8µs (4+4) within Module::Load::BEGIN@14 which was called:
# once (4µs+4µs) by Module::Load::Conditional::BEGIN@5 at line 14 # spent 8µs making 1 call to Module::Load::BEGIN@14
# spent 4µs making 1 call to strict::unimport |
| 15 | |||||
| 16 | @_ or ( | ||||
| 17 | *{"${who}::load"} = \&load, # compat to prev version | ||||
| 18 | 1 | 100ns | *{"${who}::autoload"} = \&autoload, | ||
| 19 | return | ||||
| 20 | ); | ||||
| 21 | |||||
| 22 | 1 | 2µs | map { $h->{$_} = () if defined $_ } @_; | ||
| 23 | |||||
| 24 | 1 | 400ns | (exists $h->{none} or exists $h->{''}) | ||
| 25 | and shift, last; | ||||
| 26 | |||||
| 27 | ((exists $h->{autoload} and shift,1) or (exists $h->{all} and shift)) | ||||
| 28 | 1 | 100ns | and *{"${who}::autoload"} = \&autoload; | ||
| 29 | |||||
| 30 | ((exists $h->{load} and shift,1) or exists $h->{all}) | ||||
| 31 | 1 | 2µs | and *{"${who}::load"} = \&load; | ||
| 32 | |||||
| 33 | ((exists $h->{load_remote} and shift,1) or exists $h->{all}) | ||||
| 34 | 1 | 200ns | and *{"${who}::load_remote"} = \&load_remote; | ||
| 35 | |||||
| 36 | ((exists $h->{autoload_remote} and shift,1) or exists $h->{all}) | ||||
| 37 | 1 | 1µs | and *{"${who}::autoload_remote"} = \&autoload_remote; | ||
| 38 | |||||
| 39 | } | ||||
| 40 | |||||
| 41 | } | ||||
| 42 | |||||
| 43 | sub load(*;@){ | ||||
| 44 | goto &_load; | ||||
| 45 | } | ||||
| 46 | |||||
| 47 | sub autoload(*;@){ | ||||
| 48 | unshift @_, 'autoimport'; | ||||
| 49 | goto &_load; | ||||
| 50 | } | ||||
| 51 | |||||
| 52 | sub load_remote($$;@){ | ||||
| 53 | my ($dst, $src, @exp) = @_; | ||||
| 54 | |||||
| 55 | eval "package $dst;Module::Load::load('$src', qw/@exp/);"; | ||||
| 56 | $@ && die "$@"; | ||||
| 57 | } | ||||
| 58 | |||||
| 59 | sub autoload_remote($$;@){ | ||||
| 60 | my ($dst, $src, @exp) = @_; | ||||
| 61 | |||||
| 62 | eval "package $dst;Module::Load::autoload('$src', qw/@exp/);"; | ||||
| 63 | $@ && die "$@"; | ||||
| 64 | } | ||||
| 65 | |||||
| 66 | sub _load{ | ||||
| 67 | my $autoimport = $_[0] eq 'autoimport' and shift; | ||||
| 68 | my $mod = shift or return; | ||||
| 69 | my $who = _who(); | ||||
| 70 | |||||
| 71 | if( _is_file( $mod ) ) { | ||||
| 72 | require $mod; | ||||
| 73 | } else { | ||||
| 74 | LOAD: { | ||||
| 75 | my $err; | ||||
| 76 | for my $flag ( qw[1 0] ) { | ||||
| 77 | my $file = _to_file( $mod, $flag); | ||||
| 78 | eval { require $file }; | ||||
| 79 | $@ ? $err .= $@ : last LOAD; | ||||
| 80 | } | ||||
| 81 | die $err if $err; | ||||
| 82 | } | ||||
| 83 | } | ||||
| 84 | |||||
| 85 | ### This addresses #41883: Module::Load cannot import | ||||
| 86 | ### non-Exporter module. ->import() routines weren't | ||||
| 87 | ### properly called when load() was used. | ||||
| 88 | |||||
| 89 | 2 | 243µs | 2 | 12µs | # spent 8µs (5+3) within Module::Load::BEGIN@89 which was called:
# once (5µs+3µs) by Module::Load::Conditional::BEGIN@5 at line 89 # spent 8µs making 1 call to Module::Load::BEGIN@89
# spent 3µs making 1 call to strict::unimport |
| 90 | my $import; | ||||
| 91 | |||||
| 92 | ((@_ or $autoimport) and ( | ||||
| 93 | $import = $mod->can('import') | ||||
| 94 | ) and ( | ||||
| 95 | unshift(@_, $mod), | ||||
| 96 | goto &$import | ||||
| 97 | ) | ||||
| 98 | ); | ||||
| 99 | } | ||||
| 100 | |||||
| 101 | } | ||||
| 102 | |||||
| 103 | sub _to_file{ | ||||
| 104 | local $_ = shift; | ||||
| 105 | my $pm = shift || ''; | ||||
| 106 | |||||
| 107 | ## trailing blanks ignored by default. [rt #69886] | ||||
| 108 | my @parts = split /::|'/, $_, -1; | ||||
| 109 | ## make sure that we can't hop out of @INC | ||||
| 110 | shift @parts if @parts && !$parts[0]; | ||||
| 111 | |||||
| 112 | ### because of [perl #19213], see caveats ### | ||||
| 113 | my $file = $^O eq 'MSWin32' | ||||
| 114 | ? join "/", @parts | ||||
| 115 | : File::Spec->catfile( @parts ); | ||||
| 116 | |||||
| 117 | $file .= '.pm' if $pm; | ||||
| 118 | |||||
| 119 | ### on perl's before 5.10 (5.9.5@31746) if you require | ||||
| 120 | ### a file in VMS format, it's stored in %INC in VMS | ||||
| 121 | ### format. Therefor, better unixify it first | ||||
| 122 | ### Patch in reply to John Malmbergs patch (as mentioned | ||||
| 123 | ### above) on p5p Tue 21 Aug 2007 04:55:07 | ||||
| 124 | $file = VMS::Filespec::unixify($file) if $^O eq 'VMS'; | ||||
| 125 | |||||
| 126 | return $file; | ||||
| 127 | } | ||||
| 128 | |||||
| 129 | 1 | 3µs | 1 | 6µs | # spent 9µs (4+6) within Module::Load::_who which was called:
# once (4µs+6µs) by Module::Load::import at line 11 # spent 6µs making 1 call to Contextual::Return::__ANON__[Contextual/Return.pm:30] |
| 130 | |||||
| 131 | sub _is_file { | ||||
| 132 | local $_ = shift; | ||||
| 133 | return /^\./ ? 1 : | ||||
| 134 | /[^\w:']/ ? 1 : | ||||
| 135 | undef | ||||
| 136 | } | ||||
| 137 | |||||
| - - | |||||
| 140 | 1 | 2µs | 1; | ||
| 141 | |||||
| 142 | __END__ |