line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Use; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.005; |
4
|
1
|
|
|
1
|
|
1723
|
use Tie::Hash; |
|
1
|
|
|
|
|
1000
|
|
|
1
|
|
|
|
|
28
|
|
5
|
|
|
|
|
|
|
#use Tie::StdHash; |
6
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
7
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
35
|
|
8
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION %noargs %counts %config $_object @ISA); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
923
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@ISA = qw(Tie::StdHash); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$VERSION = 0.05_01; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
@noargs{ |
15
|
|
|
|
|
|
|
qw(Counting) |
16
|
|
|
|
|
|
|
} = ( ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub FETCH { |
19
|
0
|
0
|
|
0
|
|
|
$counts{$_[1]}++ if defined $_[0] -> {$_[1]}; |
20
|
0
|
|
|
|
|
|
warn "Fetching $_[1]\n"; |
21
|
0
|
|
|
|
|
|
$_[0] -> {$_[1]}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub STORE { |
25
|
0
|
|
|
0
|
|
|
$counts{$_[1]}++; |
26
|
0
|
|
|
|
|
|
warn "Storing $_[1]\n"; |
27
|
0
|
|
|
|
|
|
$_[0] -> {$_[1]} = $_[2]; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub import { |
31
|
0
|
|
|
0
|
|
|
my($self, @config) = @_; |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
croak "@{[ref $self]} not intended to be instanced" if ref $self; |
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $op; |
36
|
0
|
|
|
|
|
|
while(@config) { |
37
|
0
|
|
|
|
|
|
$op = shift @config; |
38
|
0
|
0
|
|
|
|
|
if(exists $noargs{$op}) { |
39
|
0
|
|
|
|
|
|
$config{$op} = 1; |
40
|
|
|
|
|
|
|
} else { |
41
|
0
|
|
|
|
|
|
$config{$op} = shift @config; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# load logging module - defines Module::Use::log |
46
|
0
|
0
|
|
|
|
|
if(defined $config{Logger}) { |
47
|
0
|
|
|
|
|
|
eval qq{require Module::Use::$config{Logger}}; |
48
|
0
|
0
|
|
|
|
|
croak "Unable to load logger: $@" if $@; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
if($ENV{'MOD_PERL'}) { |
52
|
0
|
|
|
|
|
|
$config{log_at_end} = 0; |
53
|
|
|
|
|
|
|
} else { |
54
|
0
|
|
|
|
|
|
$config{log_at_end} = 1; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
if($config{"Counting"}) { |
58
|
0
|
|
|
|
|
|
tie %INC, $self; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$_object = tied %INC; |
61
|
|
|
|
|
|
|
} else { |
62
|
0
|
|
|
|
|
|
$_object = bless { }, $self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my($modules) = $_object -> query_modules(); |
66
|
0
|
|
|
|
|
|
eval "require $_" for @{$modules}; |
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub query_modules { |
70
|
0
|
|
|
0
|
0
|
|
my($self) = shift; |
71
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
return unless $self -> can('_query_modules'); |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my $hash = $self -> _query_modules(); |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my @keys = keys %{$hash}; |
|
0
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $total = 0; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
local($_); # JIC |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$total += $hash->{$_} for @keys; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $p = 0; |
84
|
0
|
0
|
|
|
|
|
if($self -> {Percentage}) { |
85
|
0
|
|
|
|
|
|
$p = $self -> {Percentage} * $total / 100.; |
86
|
|
|
|
|
|
|
} |
87
|
0
|
0
|
|
|
|
|
if($self -> {Count}) { |
88
|
0
|
0
|
|
|
|
|
if($p < $self -> {Count}) { |
89
|
0
|
|
|
|
|
|
$p = $self -> {Count}; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my $l; |
94
|
0
|
0
|
|
|
|
|
if($self -> {Limit}) { |
95
|
0
|
|
|
|
|
|
$l = $self -> {Limit}; |
96
|
|
|
|
|
|
|
} else { |
97
|
0
|
|
|
|
|
|
$l = scalar(@keys); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
@keys = sort { $hash->{$a} <=> $hash->{$b} } @keys; |
|
0
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
0
|
0
|
|
|
|
|
$#keys = $l-1 if $l; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
0
|
0
|
|
|
|
|
@keys = grep { $hash->{$_} > $p } @keys if $p; # could do a binary search at this point |
|
0
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
@keys = map s{\.pm$}{}, map s{/}{::}, @keys; |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
return \@keys; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub _process_INC { |
113
|
0
|
0
|
|
0
|
|
|
if($config{"Counting"}) { |
114
|
0
|
|
0
|
|
|
|
return grep { $_ !~ m{^Module/Use(/|\.pm)?} |
|
0
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
&& $_ !~ m{^[a-z/]} |
116
|
|
|
|
|
|
|
} keys %counts; |
117
|
|
|
|
|
|
|
} else { |
118
|
0
|
|
0
|
|
|
|
return grep { $_ !~ m{^Module/Use(/|\.pm)?} |
|
0
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
&& $_ !~ m{^[a-z/]} |
120
|
|
|
|
|
|
|
} keys %INC; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub handler { |
125
|
1
|
|
|
1
|
|
6
|
no strict qw(subs); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
134
|
|
126
|
|
|
|
|
|
|
|
127
|
0
|
0
|
|
0
|
0
|
|
$_object -> log(_process_INC()) if $_object -> can("log"); |
128
|
0
|
|
|
|
|
|
return Apache::Constants::OK; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
END { |
132
|
|
|
|
|
|
|
# now log %INC |
133
|
1
|
50
|
33
|
1
|
|
|
$_object -> log(_process_INC()) if $config{log_at_end} && $_object -> can("log"); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
__END__ |