| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Getopt::Yath::Util; |
|
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
46
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use Carp qw/confess longmess croak/; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
44
|
|
|
6
|
1
|
|
|
1
|
|
970
|
use Cpanel::JSON::XS(); |
|
|
1
|
|
|
|
|
6525
|
|
|
|
1
|
|
|
|
|
43
|
|
|
7
|
1
|
|
|
1
|
|
706
|
use Importer Importer => 'import'; |
|
|
1
|
|
|
|
|
5103
|
|
|
|
1
|
|
|
|
|
7
|
|
|
8
|
1
|
|
|
1
|
|
940
|
use File::Temp qw/ tempfile /; |
|
|
1
|
|
|
|
|
19799
|
|
|
|
1
|
|
|
|
|
811
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '2.000007'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw{ |
|
13
|
|
|
|
|
|
|
decode_json |
|
14
|
|
|
|
|
|
|
encode_json |
|
15
|
|
|
|
|
|
|
encode_json_file |
|
16
|
|
|
|
|
|
|
decode_json_file |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
fqmod |
|
19
|
|
|
|
|
|
|
mod2file |
|
20
|
|
|
|
|
|
|
}; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $json = Cpanel::JSON::XS->new->utf8(1)->convert_blessed(1)->allow_nonref(1); |
|
23
|
|
|
|
|
|
|
my $ascii = Cpanel::JSON::XS->new->ascii(1)->convert_blessed(1)->allow_nonref(1); |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
|
0
|
0
|
1
|
0
|
sub decode_json { my $out; eval { $out = $json->decode(@_); 1} // confess($@); $out } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
26
|
0
|
|
0
|
0
|
1
|
0
|
sub encode_json { my $out; eval { $out = $ascii->encode(@_); 1} // confess($@); $out } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub encode_json_file { |
|
29
|
0
|
|
|
0
|
1
|
0
|
my ($data) = @_; |
|
30
|
0
|
|
|
|
|
0
|
my $json = encode_json($data); |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
my ($fh, $file) = tempfile("$$-XXXXXX", TMPDIR => 1, SUFFIX => '.json', UNLINK => 0); |
|
33
|
0
|
|
|
|
|
0
|
print $fh $json; |
|
34
|
0
|
|
|
|
|
0
|
close($fh); |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
return $file; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub decode_json_file { |
|
40
|
0
|
|
|
0
|
1
|
0
|
my ($file, %params) = @_; |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
0
|
open(my $fh, '<', $file) or die "Could not open '$file': $!"; |
|
43
|
0
|
|
|
|
|
0
|
my $json = do { local $/; <$fh> }; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
0
|
if ($params{unlink}) { |
|
46
|
0
|
0
|
|
|
|
0
|
unlink($file) or warn "Could not unlink '$file': $!"; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
return decode_json($json); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub mod2file { |
|
53
|
16
|
|
|
16
|
1
|
29
|
my ($mod) = @_; |
|
54
|
16
|
50
|
|
|
|
29
|
confess "No module name provided" unless $mod; |
|
55
|
16
|
|
|
|
|
24
|
my $file = $mod; |
|
56
|
16
|
|
|
|
|
90
|
$file =~ s{::}{/}g; |
|
57
|
16
|
|
|
|
|
24
|
$file .= ".pm"; |
|
58
|
16
|
|
|
|
|
4256
|
return $file; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub fqmod { |
|
62
|
16
|
|
|
16
|
1
|
37
|
my ($input, $prefixes, %options) = @_; |
|
63
|
|
|
|
|
|
|
|
|
64
|
16
|
50
|
|
|
|
34
|
croak "At least 1 prefix is required" unless $prefixes; |
|
65
|
|
|
|
|
|
|
|
|
66
|
16
|
50
|
|
|
|
51
|
$prefixes = [$prefixes] unless ref($prefixes) eq 'ARRAY'; |
|
67
|
|
|
|
|
|
|
|
|
68
|
16
|
50
|
|
|
|
44
|
croak "At least 1 prefix is required" unless @$prefixes; |
|
69
|
16
|
50
|
33
|
|
|
49
|
croak "Cannot use no_require when providing multiple prefixes" if $options{no_require} && @$prefixes > 1; |
|
70
|
|
|
|
|
|
|
|
|
71
|
16
|
50
|
|
|
|
53
|
if ($input =~ m/^\+(.*)$/) { |
|
72
|
0
|
|
|
|
|
0
|
my $mod = $1; |
|
73
|
0
|
0
|
|
|
|
0
|
return $mod if $options{no_require}; |
|
74
|
0
|
0
|
|
|
|
0
|
return $mod if eval { require(mod2file($mod)); 1 }; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
75
|
0
|
|
|
|
|
0
|
confess($@); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
16
|
|
|
|
|
21
|
my %tried; |
|
79
|
16
|
|
|
|
|
33
|
for my $pre (@$prefixes) { |
|
80
|
16
|
50
|
|
|
|
141
|
my $mod = $input =~ m/^\Q$pre\E/ ? $input : "$pre\::$input"; |
|
81
|
|
|
|
|
|
|
|
|
82
|
16
|
50
|
|
|
|
41
|
if ($options{no_require}) { |
|
83
|
0
|
|
|
|
|
0
|
return $mod; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
else { |
|
86
|
16
|
50
|
|
|
|
26
|
return $mod if eval { require(mod2file($mod)); 1 }; |
|
|
16
|
|
|
|
|
52
|
|
|
|
16
|
|
|
|
|
136
|
|
|
87
|
0
|
|
|
|
|
|
($tried{$mod}) = split /\n/, $@; |
|
88
|
0
|
|
|
|
|
|
$tried{$mod} =~ s{^(Can't locate \S+ in \@INC).*$}{$1.}; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my @caller = caller; |
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
die "Could not locate a module matching '$input' at $caller[1] line $caller[2], the following were checked:\n" . join("\n", map { " * $_: $tried{$_}" } sort keys %tried) . "\n"; |
|
|
0
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |