line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Reload; |
2
|
|
|
|
|
|
|
$Module::Reload::VERSION = '1.10'; |
3
|
2
|
|
|
2
|
|
26726
|
use 5.006; |
|
2
|
|
|
|
|
8
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
47
|
|
5
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
906
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $Debug = 0; |
8
|
|
|
|
|
|
|
our %Stat; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub check { |
11
|
4
|
|
|
4
|
0
|
1002485
|
my $c=0; |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
|
|
114
|
foreach my $entry (map { [ $_, $INC{$_} ] } keys %INC) { |
|
291
|
|
|
|
|
831
|
|
14
|
291
|
|
|
|
|
595
|
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
|
291
|
100
|
|
|
|
669
|
next unless defined($file); |
19
|
|
|
|
|
|
|
|
20
|
290
|
100
|
|
|
|
722
|
next if $file eq $INC{"Module/Reload.pm"}; #too confusing |
21
|
286
|
|
|
|
|
761
|
local $^W = 0; |
22
|
286
|
|
|
|
|
7171
|
my $mtime = (stat $file)[9]; |
23
|
286
|
100
|
|
|
|
1196
|
$Stat{$file} = $^T unless defined $Stat{$file}; |
24
|
|
|
|
|
|
|
|
25
|
286
|
50
|
|
|
|
627
|
if ($Debug >= 3) { |
26
|
0
|
|
|
|
|
0
|
warn "Module::Reload: stat '$file' got $mtime >? $Stat{$file}\n"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
286
|
100
|
|
|
|
739
|
if ($mtime > $Stat{$file}) { |
30
|
2
|
|
|
|
|
7
|
delete $INC{$key}; |
31
|
2
|
|
|
|
|
5
|
eval { |
32
|
2
|
|
|
|
|
18
|
local $SIG{__WARN__} = \&warn; |
33
|
2
|
|
|
|
|
696
|
require $key; |
34
|
|
|
|
|
|
|
}; |
35
|
2
|
50
|
|
|
|
16
|
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
|
286
|
|
|
|
|
932
|
$Stat{$file} = $mtime; |
50
|
|
|
|
|
|
|
} |
51
|
4
|
|
|
|
|
88
|
$c; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |