line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::LocalLoad; |
2
|
2
|
|
|
2
|
|
69539
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
83
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
243
|
|
4
|
2
|
|
|
2
|
|
12
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
28
|
|
|
2
|
|
|
|
|
184
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.172'; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
12
|
use Carp(); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
54
|
|
8
|
2
|
|
|
2
|
|
2335
|
use File::Copy(); |
|
2
|
|
|
|
|
15235
|
|
|
2
|
|
|
|
|
169
|
|
9
|
2
|
|
|
2
|
|
20
|
use File::Path(); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
112
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $PERL_HACK_LIB = $ENV{PERL_HACK_LIB}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub import { |
14
|
2
|
|
|
2
|
|
29
|
my $who = (caller(1))[0]; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
{ |
17
|
2
|
|
|
2
|
|
11
|
no strict 'refs'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1247
|
|
|
2
|
|
|
|
|
5
|
|
18
|
2
|
|
|
|
|
5
|
*{"${who}::load"} = *load; |
|
2
|
|
|
|
|
2224
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub load { |
24
|
0
|
0
|
|
0
|
1
|
|
my $module = shift or return; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my $who = (caller(1))[0]; |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
if(!defined($PERL_HACK_LIB)) { |
29
|
0
|
|
|
|
|
|
Carp::croak("Environment variable \$PERL_HACK_LIB not set! Aborting.\n"); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $slashed_module = _colon_to_slash( $module ); |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
if(! -d "$PERL_HACK_LIB/$slashed_module") { |
35
|
0
|
0
|
|
|
|
|
File::Path::make_path("$PERL_HACK_LIB/$slashed_module") |
36
|
|
|
|
|
|
|
or Carp::croak("Cant mkdir $PERL_HACK_LIB/$slashed_module: $!\n"); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $found_pm; |
40
|
0
|
|
|
|
|
|
for my $dir_in_inc(@INC) { |
41
|
0
|
0
|
|
|
|
|
if($dir_in_inc eq $PERL_HACK_LIB) { |
42
|
0
|
|
|
|
|
|
next; |
43
|
|
|
|
|
|
|
} |
44
|
0
|
0
|
|
|
|
|
if( -f "$dir_in_inc/$slashed_module.pm") { |
45
|
0
|
|
|
|
|
|
$found_pm = "$dir_in_inc/$slashed_module.pm"; |
46
|
0
|
|
|
|
|
|
last; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if(!defined($found_pm)) { |
51
|
0
|
|
|
|
|
|
Carp::croak("Could not find $module in \@INC\n"); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
if(! -f "$PERL_HACK_LIB/$slashed_module.pm") { |
55
|
0
|
0
|
|
|
|
|
File::Copy::copy($found_pm, "$PERL_HACK_LIB/$slashed_module.pm") |
56
|
|
|
|
|
|
|
or Carp::croak( |
57
|
|
|
|
|
|
|
"Can not copy $found_pm to $PERL_HACK_LIB/$slashed_module.pm: $!" |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
unshift(@INC, $PERL_HACK_LIB) unless $INC[0] eq $PERL_HACK_LIB; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
eval "require $module"; |
64
|
0
|
0
|
|
|
|
|
$@ ? Carp::croak("Error loading $module: $@\n") : return 1; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
0
|
|
|
sub _colon_to_slash { return join('/', split(/::/, shift)) } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |