line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
683
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
47
|
|
2
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
32
|
|
3
|
2
|
|
|
2
|
|
7
|
use utf8; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
12
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package App::RecordStream::Operation::tojsonarray; |
6
|
2
|
|
|
2
|
|
52
|
use base qw(App::RecordStream::Operation); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
361
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub init { |
9
|
2
|
|
|
2
|
0
|
4
|
my $this = shift; |
10
|
2
|
|
|
|
|
3
|
my $args = shift; |
11
|
2
|
|
|
|
|
8
|
$this->parse_options($args); |
12
|
2
|
|
|
|
|
5
|
$this->{COUNT} = 0; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub accept_line { |
16
|
4
|
|
|
4
|
0
|
6
|
my $this = shift; |
17
|
4
|
|
|
|
|
5
|
my $line = shift; |
18
|
|
|
|
|
|
|
$this->push_line( |
19
|
4
|
100
|
|
|
|
297
|
$this->{COUNT}++ == 0 |
20
|
|
|
|
|
|
|
? "[$line" |
21
|
|
|
|
|
|
|
: ",$line" |
22
|
|
|
|
|
|
|
); |
23
|
4
|
|
|
|
|
16
|
return 1; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub stream_done { |
27
|
2
|
|
|
2
|
0
|
4
|
my $this = shift; |
28
|
|
|
|
|
|
|
$this->push_line( |
29
|
|
|
|
|
|
|
$this->{COUNT} |
30
|
2
|
100
|
|
|
|
5
|
? "]" |
31
|
|
|
|
|
|
|
: "[]" |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub usage { |
36
|
0
|
|
|
0
|
0
|
|
my $this = shift; |
37
|
0
|
|
|
|
|
|
return <
|
38
|
|
|
|
|
|
|
Usage: recs tojsonarray [files] |
39
|
|
|
|
|
|
|
__FORMAT_TEXT__ |
40
|
|
|
|
|
|
|
This command outputs the record stream as a single JSON array. It |
41
|
|
|
|
|
|
|
complements the fromjsonarray command. |
42
|
|
|
|
|
|
|
__FORMAT_TEXT__ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Examples |
45
|
|
|
|
|
|
|
# Save the record stream to a file suitable for loading by any JSON parser |
46
|
|
|
|
|
|
|
... | recs tojsonarray > recs.json |
47
|
|
|
|
|
|
|
USAGE |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |