line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Reload; |
2
|
|
|
|
|
|
|
$Module::Reload::VERSION = '1.12'; |
3
|
2
|
|
|
2
|
|
80037
|
use 5.006; |
|
2
|
|
|
|
|
14
|
|
4
|
2
|
|
|
2
|
|
20
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
43
|
|
5
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
842
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $Debug = 0; |
8
|
|
|
|
|
|
|
our %Stat; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub check { |
11
|
4
|
|
|
4
|
0
|
1001618
|
my $c=0; |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
|
|
118
|
foreach my $entry (map { [ $_, $INC{$_} ] } keys %INC) { |
|
331
|
|
|
|
|
755
|
|
14
|
331
|
|
|
|
|
706
|
my($key,$file) = @$entry; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# If the require'ing of a file failed, but was caught by eval, |
17
|
|
|
|
|
|
|
# then we end up with a value of undef in %INC. Skip those. |
18
|
331
|
100
|
|
|
|
611
|
next unless defined($file); |
19
|
|
|
|
|
|
|
|
20
|
330
|
100
|
|
|
|
690
|
next if $file eq $INC{"Module/Reload.pm"}; #too confusing |
21
|
326
|
|
|
|
|
839
|
local $^W = 0; |
22
|
326
|
|
|
|
|
5110
|
my $mtime = (stat $file)[9]; |
23
|
326
|
100
|
|
|
|
1521
|
$Stat{$file} = $^T unless defined $Stat{$file}; |
24
|
|
|
|
|
|
|
|
25
|
326
|
50
|
|
|
|
672
|
if ($Debug >= 3) { |
26
|
0
|
|
|
|
|
0
|
warn "Module::Reload: stat '$file' got $mtime >? $Stat{$file}\n"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
326
|
100
|
|
|
|
641
|
if ($mtime > $Stat{$file}) { |
30
|
2
|
|
|
|
|
7
|
delete $INC{$key}; |
31
|
2
|
|
|
|
|
6
|
eval { |
32
|
2
|
|
|
|
|
18
|
local $SIG{__WARN__} = \&warn; |
33
|
2
|
|
|
|
|
326
|
require $key; |
34
|
|
|
|
|
|
|
}; |
35
|
2
|
50
|
|
|
|
17
|
if ($@) { |
|
|
50
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
warn "Module::Reload: error during reload of '$key': $@\n"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
elsif ($Debug) { |
39
|
0
|
0
|
|
|
|
0
|
if ($Debug == 1) { |
40
|
0
|
|
|
|
|
0
|
warn "Module::Reload: process $$ reloaded '$key'\n"; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
0
|
|
|
|
0
|
if ($Debug >= 2) { |
43
|
0
|
|
|
|
|
0
|
warn("Module::Reload: process $$ reloaded '$key' (\@INC=". |
44
|
|
|
|
|
|
|
join(', ',@INC).")\n"); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
2
|
|
|
|
|
5
|
++$c; |
48
|
|
|
|
|
|
|
} |
49
|
326
|
|
|
|
|
1014
|
$Stat{$file} = $mtime; |
50
|
|
|
|
|
|
|
} |
51
|
4
|
|
|
|
|
78
|
$c; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |