line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Require; |
6
|
|
|
|
|
|
|
|
7
|
105
|
|
|
105
|
|
74147
|
use v5.12.5; |
|
105
|
|
|
|
|
396
|
|
8
|
105
|
|
|
105
|
|
560
|
use warnings; |
|
105
|
|
|
|
|
221
|
|
|
105
|
|
|
|
|
5114
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.2.2'; # TRIAL VERSION |
11
|
|
|
|
|
|
|
|
12
|
105
|
|
|
105
|
|
658
|
use Carp; |
|
105
|
|
|
|
|
216
|
|
|
105
|
|
|
|
|
7343
|
|
13
|
|
|
|
|
|
|
require Rex::Logger; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# some code borrowed from: UNIVERSAL::require (neilb) |
16
|
|
|
|
|
|
|
|
17
|
105
|
|
|
105
|
|
58493
|
BEGIN { require UNIVERSAL; } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $module_name_rx = qr/[A-Z_a-z][0-9A-Z_a-z]*(?:::[0-9A-Z_a-z]+)*/; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub UNIVERSAL::require { |
22
|
399
|
|
|
399
|
0
|
4048
|
my ( $module, %option ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
399
|
|
100
|
|
|
3960
|
$option{level} ||= 0; |
25
|
|
|
|
|
|
|
|
26
|
399
|
|
|
|
|
7637
|
my ( $caller_package, $caller_file, $caller_line ) = caller( $option{level} ); |
27
|
|
|
|
|
|
|
|
28
|
399
|
|
|
|
|
3066
|
my $file = $module . ".pm"; |
29
|
399
|
|
|
|
|
3859
|
$file =~ s/::/\//g; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# check if module is already loaded. |
32
|
399
|
100
|
|
|
|
2236
|
return eval { 1 } if $INC{$file}; |
|
139
|
|
|
|
|
521
|
|
33
|
|
|
|
|
|
|
|
34
|
260
|
|
|
|
|
29123
|
my $ret = eval "CORE::require(\$file)"; |
35
|
|
|
|
|
|
|
|
36
|
260
|
100
|
|
|
|
1413105
|
if ( !$ret ) { |
37
|
105
|
|
|
|
|
110446
|
confess $@; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
155
|
|
|
|
|
1161
|
return $ret; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub UNIVERSAL::use { |
44
|
67
|
|
|
67
|
0
|
955
|
my ( $module, @imports ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
67
|
|
|
|
|
1899
|
$module->require( level => 1 ); |
47
|
|
|
|
|
|
|
|
48
|
66
|
|
|
|
|
788
|
my ( $caller_package, $caller_file, $caller_line ) = caller(0); |
49
|
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
7211
|
eval "package $caller_package;\n\$module->import(\@imports);\n1;"; |
51
|
|
|
|
|
|
|
|
52
|
66
|
50
|
|
|
|
704
|
if ($@) { |
53
|
0
|
|
|
|
|
0
|
confess $@; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
66
|
|
|
|
|
1485
|
return 1; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub UNIVERSAL::is_loadable { |
60
|
118
|
|
|
118
|
0
|
397
|
my ($module) = @_; |
61
|
118
|
|
|
|
|
252
|
eval { |
62
|
118
|
|
|
|
|
791
|
$module->require; |
63
|
117
|
|
|
|
|
234
|
1; |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
|
66
|
118
|
100
|
|
|
|
680
|
if ($@) { return 0; } |
|
1
|
|
|
|
|
1870
|
|
67
|
117
|
|
|
|
|
1033
|
return 1; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |