line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Reload; |
2
|
|
|
|
|
|
|
$Module::Reload::VERSION = '1.11'; |
3
|
2
|
|
|
2
|
|
21104
|
use 5.006; |
|
2
|
|
|
|
|
4
|
|
4
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
35
|
|
5
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
551
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $Debug = 0; |
8
|
|
|
|
|
|
|
our %Stat; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub check { |
11
|
4
|
|
|
4
|
0
|
1000915
|
my $c=0; |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
|
|
101
|
foreach my $entry (map { [ $_, $INC{$_} ] } keys %INC) { |
|
295
|
|
|
|
|
469
|
|
14
|
295
|
|
|
|
|
350
|
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
|
295
|
100
|
|
|
|
369
|
next unless defined($file); |
19
|
|
|
|
|
|
|
|
20
|
294
|
100
|
|
|
|
378
|
next if $file eq $INC{"Module/Reload.pm"}; #too confusing |
21
|
290
|
|
|
|
|
419
|
local $^W = 0; |
22
|
290
|
|
|
|
|
3864
|
my $mtime = (stat $file)[9]; |
23
|
290
|
100
|
|
|
|
740
|
$Stat{$file} = $^T unless defined $Stat{$file}; |
24
|
|
|
|
|
|
|
|
25
|
290
|
50
|
|
|
|
358
|
if ($Debug >= 3) { |
26
|
0
|
|
|
|
|
0
|
warn "Module::Reload: stat '$file' got $mtime >? $Stat{$file}\n"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
290
|
100
|
|
|
|
438
|
if ($mtime > $Stat{$file}) { |
30
|
2
|
|
|
|
|
6
|
delete $INC{$key}; |
31
|
2
|
|
|
|
|
4
|
eval { |
32
|
2
|
|
|
|
|
13
|
local $SIG{__WARN__} = \&warn; |
33
|
2
|
|
|
|
|
138
|
require $key; |
34
|
|
|
|
|
|
|
}; |
35
|
2
|
50
|
|
|
|
11
|
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
|
|
|
|
|
3
|
++$c; |
48
|
|
|
|
|
|
|
} |
49
|
290
|
|
|
|
|
502
|
$Stat{$file} = $mtime; |
50
|
|
|
|
|
|
|
} |
51
|
4
|
|
|
|
|
59
|
$c; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |