line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Require; |
6
|
|
|
|
|
|
|
|
7
|
105
|
|
|
105
|
|
73216
|
use v5.12.5; |
|
105
|
|
|
|
|
360
|
|
8
|
105
|
|
|
105
|
|
547
|
use warnings; |
|
105
|
|
|
|
|
222
|
|
|
105
|
|
|
|
|
4836
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.3'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
105
|
|
|
105
|
|
681
|
use Carp; |
|
105
|
|
|
|
|
210
|
|
|
105
|
|
|
|
|
7035
|
|
13
|
|
|
|
|
|
|
require Rex::Logger; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# some code borrowed from: UNIVERSAL::require (neilb) |
16
|
|
|
|
|
|
|
|
17
|
105
|
|
|
105
|
|
55638
|
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
|
3132
|
my ( $module, %option ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
399
|
|
100
|
|
|
3771
|
$option{level} ||= 0; |
25
|
|
|
|
|
|
|
|
26
|
399
|
|
|
|
|
6827
|
my ( $caller_package, $caller_file, $caller_line ) = caller( $option{level} ); |
27
|
|
|
|
|
|
|
|
28
|
399
|
|
|
|
|
2496
|
my $file = $module . ".pm"; |
29
|
399
|
|
|
|
|
3524
|
$file =~ s/::/\//g; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# check if module is already loaded. |
32
|
399
|
100
|
|
|
|
2164
|
return eval { 1 } if $INC{$file}; |
|
137
|
|
|
|
|
546
|
|
33
|
|
|
|
|
|
|
|
34
|
262
|
|
|
|
|
25397
|
my $ret = eval "CORE::require(\$file)"; |
35
|
|
|
|
|
|
|
|
36
|
262
|
100
|
|
|
|
1383177
|
if ( !$ret ) { |
37
|
105
|
|
|
|
|
106869
|
confess $@; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
157
|
|
|
|
|
1206
|
return $ret; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub UNIVERSAL::use { |
44
|
67
|
|
|
67
|
0
|
698
|
my ( $module, @imports ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
67
|
|
|
|
|
1789
|
$module->require( level => 1 ); |
47
|
|
|
|
|
|
|
|
48
|
66
|
|
|
|
|
786
|
my ( $caller_package, $caller_file, $caller_line ) = caller(0); |
49
|
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
6746
|
eval "package $caller_package;\n\$module->import(\@imports);\n1;"; |
51
|
|
|
|
|
|
|
|
52
|
66
|
50
|
|
|
|
681
|
if ($@) { |
53
|
0
|
|
|
|
|
0
|
confess $@; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
66
|
|
|
|
|
1301
|
return 1; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub UNIVERSAL::is_loadable { |
60
|
118
|
|
|
118
|
0
|
389
|
my ($module) = @_; |
61
|
118
|
|
|
|
|
247
|
eval { |
62
|
118
|
|
|
|
|
826
|
$module->require; |
63
|
117
|
|
|
|
|
271
|
1; |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
|
66
|
118
|
100
|
|
|
|
592
|
if ($@) { return 0; } |
|
1
|
|
|
|
|
1869
|
|
67
|
117
|
|
|
|
|
955
|
return 1; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |