| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Detect::Module - allows autodetection of Perl modules. |
|
4
|
|
|
|
|
|
|
# Copyright (C) 2001 Rudolf Polzer |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# This library is free software; you can redistribute it and/or |
|
7
|
|
|
|
|
|
|
# modify it under the terms of the GNU Library General Public |
|
8
|
|
|
|
|
|
|
# License as published by the Free Software Foundation; either |
|
9
|
|
|
|
|
|
|
# version 2 of the License, or (at your option) any later version. |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# This library is distributed in the hope that it will be useful, |
|
12
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14
|
|
|
|
|
|
|
# Library General Public License for more details. |
|
15
|
|
|
|
|
|
|
# |
|
16
|
|
|
|
|
|
|
# You should have received a copy of the GNU Library General Public |
|
17
|
|
|
|
|
|
|
# License along with this library; if not, write to the Free |
|
18
|
|
|
|
|
|
|
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
package Detect::Module; |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
668
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
522
|
|
|
25
|
|
|
|
|
|
|
require Exporter; |
|
26
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
27
|
|
|
|
|
|
|
@EXPORT = (); |
|
28
|
|
|
|
|
|
|
@EXPORT_OK = qw(Use Require NewRef Load); |
|
29
|
|
|
|
|
|
|
%EXPORT_TAGS = (standard => [@EXPORT_OK]); |
|
30
|
|
|
|
|
|
|
$VERSION = '1.2'; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $DEBUG = 0; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub Debug ($) |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
0
|
0
|
|
0
|
1
|
0
|
$DEBUG = $_[0] ? 1 : 0; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my %FAIL; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub Reset |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
0
|
|
|
0
|
1
|
0
|
%FAIL = (); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub Use (@) |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
5
|
|
|
5
|
1
|
80
|
for (@_) |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
7
|
50
|
|
|
|
23
|
if (exists $FAIL{$_}) |
|
51
|
|
|
|
|
|
|
{ |
|
52
|
0
|
0
|
|
|
|
0
|
print STDERR "Not trying $_ any more\n" |
|
53
|
|
|
|
|
|
|
if $DEBUG; |
|
54
|
0
|
|
|
|
|
0
|
next; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
7
|
50
|
|
|
|
15
|
print STDERR "Trying $_\n" |
|
57
|
|
|
|
|
|
|
if $DEBUG; |
|
58
|
7
|
100
|
|
|
|
26
|
if (/[^A-Za-z0-9\_\:\.]/) |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
2
|
50
|
|
|
|
6
|
print STDERR "$_ rejected - invalid characters\n" |
|
61
|
|
|
|
|
|
|
if $DEBUG; |
|
62
|
2
|
|
|
|
|
3
|
next; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
5
|
|
|
|
|
6
|
my $s = $_; |
|
65
|
5
|
100
|
|
|
|
271
|
return $_ |
|
66
|
|
|
|
|
|
|
if eval "require $_;"; |
|
67
|
1
|
|
|
|
|
6
|
$FAIL{$s} = 1; |
|
68
|
1
|
50
|
|
|
|
5
|
print STDERR "$@\n" |
|
69
|
|
|
|
|
|
|
if $DEBUG; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
1
|
|
|
|
|
3
|
die "No module of @{[join ', ', @_]} could be found\n"; |
|
|
1
|
|
|
|
|
10
|
|
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub Require (@) |
|
75
|
|
|
|
|
|
|
{ |
|
76
|
1
|
|
|
1
|
1
|
13188
|
goto &Use; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub NewRef (@) |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
1
|
|
|
1
|
1
|
28
|
my $constructor = Use @_; |
|
82
|
|
|
|
|
|
|
return sub (@) |
|
83
|
|
|
|
|
|
|
{ |
|
84
|
0
|
|
|
0
|
|
0
|
return eval ('new ' . $constructor . ' @_'); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
1
|
|
|
|
|
21632
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub Load (@) |
|
89
|
|
|
|
|
|
|
{ |
|
90
|
1
|
|
|
1
|
1
|
41
|
my $name = Use @_; |
|
91
|
1
|
50
|
|
|
|
1298
|
$name or # new in 1.2 |
|
92
|
|
|
|
|
|
|
return undef; |
|
93
|
|
|
|
|
|
|
return bless sub ($$) |
|
94
|
|
|
|
|
|
|
{ |
|
95
|
1
|
|
|
1
|
|
10
|
no strict 'refs'; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
195
|
|
|
96
|
3
|
|
|
3
|
|
77
|
my $n = "${name}::$_[1]"; |
|
97
|
3
|
100
|
|
|
|
9
|
if ($_[0] eq 'CODECHECK') # changed in 1.2 |
|
98
|
|
|
|
|
|
|
{ |
|
99
|
|
|
|
|
|
|
eval |
|
100
|
|
|
|
|
|
|
q{ |
|
101
|
|
|
|
|
|
|
require 5.6.1; |
|
102
|
|
|
|
|
|
|
return undef unless exists &$n; |
|
103
|
|
|
|
|
|
|
1; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
or do |
|
106
|
2
|
100
|
|
|
|
137
|
{ |
|
107
|
1
|
50
|
|
|
|
16
|
return undef unless exists "${name}::"->{$_[1]}; |
|
108
|
|
|
|
|
|
|
# not perfect, but works with pre-5.6.1 versions. |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
} |
|
111
|
2
|
50
|
66
|
|
|
18
|
return \&$n if $_[0] eq 'CODE' || $_[0] eq 'CODECHECK'; |
|
112
|
0
|
0
|
|
|
|
0
|
return \%$n if $_[0] eq 'HASH'; |
|
113
|
0
|
0
|
|
|
|
0
|
return \@$n if $_[0] eq 'ARRAY'; |
|
114
|
0
|
0
|
0
|
|
|
0
|
return \*$n if $_[0] eq 'GLOB' || $_[0] eq 'HANDLE'; |
|
115
|
0
|
0
|
|
|
|
0
|
return \$$n if $_[0] eq 'SCALAR'; |
|
116
|
0
|
|
|
|
|
0
|
die 'Valid type arguments to Detect::Module::Load()-> are SCALAR,GLOB,HANDLE,ARRAY,HASH,CODE,CODECHECK'; |
|
117
|
1
|
|
|
|
|
11
|
}, 'Detect::Module::Internal'; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
package Detect::Module::Internal; |
|
121
|
|
|
|
|
|
|
|
|
122
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
123
|
1
|
|
|
1
|
|
4
|
use vars qw($AUTOLOAD); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
140
|
|
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub AUTOLOAD (@) |
|
126
|
|
|
|
|
|
|
{ |
|
127
|
2
|
|
|
2
|
|
44
|
my @l = caller (1); |
|
128
|
2
|
|
|
|
|
3
|
my $o = shift; |
|
129
|
2
|
|
|
|
|
3
|
my $f; |
|
130
|
2
|
100
|
33
|
|
|
12
|
die "Undefined subroutine $AUTOLOAD called from $l[1] at line $l[2].\n" |
|
|
|
|
66
|
|
|
|
|
|
131
|
|
|
|
|
|
|
unless ref ($o) eq __PACKAGE__ |
|
132
|
2
|
|
|
|
|
42
|
and $AUTOLOAD =~ /^@{[__PACKAGE__]}::(.*)$/ |
|
133
|
|
|
|
|
|
|
and $f = $o->('CODECHECK', $1, 1); |
|
134
|
1
|
|
|
|
|
4
|
goto &$f; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
__END__ |