| 1 | 2 | ▶ | use strict; use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | package Jq; | ||||||||||
| 3 | 2 | our $VERSION = '0.01'; | |||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use IPC::Run qw(run timeout); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | our @EXPORT = qw(jq); | |||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | sub jq { | ||||||||
|
Subroutine
jq: called CC=4 SCAR=17.9
Pod
undocumented
| |||||||||||
| 12 | 1 | my ($filter, @data) = @_; | |||||||||
| 13 | 1 | my @jq = ('jq', "$filter"); | |||||||||
| 14 | 1 | my ($in, $out, $err); | |||||||||
| 15 | 1 | for my $value (@data) { | |||||||||
| 16 | 1 | $in .= JSON::encode_json($value) . "\n"; | |||||||||
| 17 | } | ||||||||||
| 18 | 1 | ▶ | run \@jq, \$in, \$out, \$err, timeout(10) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | or die "jq: $?, $err"; | ||||||||||
| 20 | 0 | my $result = JSON::decode_json("[$out]"); | |||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | return wantarray ? @$result : $result->[0]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 2 | 1; | |||||||||