line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
44090
|
use strict; use warnings; |
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
|
|
73
|
|
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
135
|
|
2
|
|
|
|
|
|
|
package Jq; |
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
2287
|
use IPC::Run qw(run timeout); |
|
2
|
|
|
|
|
111673
|
|
|
2
|
|
|
|
|
164
|
|
6
|
2
|
|
|
2
|
|
1139
|
use JSON; |
|
2
|
|
|
|
|
21101
|
|
|
2
|
|
|
|
|
15
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
352
|
use Exporter 'import'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
479
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw(jq); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub jq { |
12
|
1
|
|
|
1
|
0
|
13
|
my ($filter, @data) = @_; |
13
|
1
|
|
|
|
|
4
|
my @jq = ('jq', "$filter"); |
14
|
1
|
|
|
|
|
3
|
my ($in, $out, $err); |
15
|
1
|
|
|
|
|
4
|
for my $value (@data) { |
16
|
1
|
|
|
|
|
29
|
$in .= JSON::encode_json($value) . "\n"; |
17
|
|
|
|
|
|
|
} |
18
|
1
|
0
|
|
|
|
10
|
run \@jq, \$in, \$out, \$err, timeout(10) |
19
|
|
|
|
|
|
|
or die "jq: $?, $err"; |
20
|
0
|
|
|
|
|
|
my $result = JSON::decode_json("[$out]"); |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
return wantarray ? @$result : $result->[0]; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |