| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Unixish; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2019-10-26'; # DATE |
|
4
|
|
|
|
|
|
|
our $VERSION = '1.572'; # VERSION |
|
5
|
|
|
|
|
|
|
|
|
6
|
46
|
|
|
46
|
|
3648
|
use 5.010001; |
|
|
46
|
|
|
|
|
156
|
|
|
7
|
46
|
|
|
46
|
|
250
|
use strict; |
|
|
46
|
|
|
|
|
104
|
|
|
|
46
|
|
|
|
|
957
|
|
|
8
|
46
|
|
|
46
|
|
213
|
use warnings; |
|
|
46
|
|
|
|
|
105
|
|
|
|
46
|
|
|
|
|
1196
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
46
|
|
|
46
|
|
19200
|
use Module::Load; |
|
|
46
|
|
|
|
|
43531
|
|
|
|
46
|
|
|
|
|
241
|
|
|
11
|
46
|
|
|
46
|
|
20684
|
use Package::Util::Lite qw(package_exists); |
|
|
46
|
|
|
|
|
17432
|
|
|
|
46
|
|
|
|
|
29504
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
require Exporter; |
|
14
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
15
|
|
|
|
|
|
|
our @EXPORT_OK = |
|
16
|
|
|
|
|
|
|
qw( |
|
17
|
|
|
|
|
|
|
aduxa cduxa fduxa lduxa |
|
18
|
|
|
|
|
|
|
aduxc cduxc fduxc lduxc |
|
19
|
|
|
|
|
|
|
aduxf cduxf fduxf lduxf |
|
20
|
|
|
|
|
|
|
aduxl cduxl fduxl lduxl |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
siduxs |
|
23
|
|
|
|
|
|
|
aiduxa aiduxl |
|
24
|
|
|
|
|
|
|
liduxa liduxl |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
27
|
|
|
|
|
|
|
all => [ |
|
28
|
|
|
|
|
|
|
qw/ |
|
29
|
|
|
|
|
|
|
aduxa cduxa fduxa lduxa |
|
30
|
|
|
|
|
|
|
aduxc cduxc fduxc lduxc |
|
31
|
|
|
|
|
|
|
aduxf cduxf fduxf lduxf |
|
32
|
|
|
|
|
|
|
aduxl cduxl fduxl lduxl |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
siduxs |
|
35
|
|
|
|
|
|
|
aiduxa aiduxl |
|
36
|
|
|
|
|
|
|
liduxa liduxl |
|
37
|
|
|
|
|
|
|
/], |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _dux { |
|
41
|
51
|
|
|
51
|
|
211
|
my $accepts = shift; |
|
42
|
51
|
|
|
|
|
146
|
my $returns = shift; |
|
43
|
|
|
|
|
|
|
|
|
44
|
51
|
|
|
|
|
132
|
my $func = shift; |
|
45
|
|
|
|
|
|
|
|
|
46
|
51
|
|
|
|
|
94
|
my %args; |
|
47
|
|
|
|
|
|
|
|
|
48
|
51
|
|
|
|
|
105
|
my ($icallback, $ocallback); |
|
49
|
51
|
100
|
|
|
|
204
|
if ($accepts eq 'c') { |
|
50
|
6
|
|
|
|
|
30
|
$icallback = shift; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
51
|
100
|
|
|
|
144
|
if ($returns eq 'c') { |
|
53
|
4
|
|
|
|
|
13
|
$ocallback = shift; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
51
|
100
|
|
|
|
351
|
if ($accepts eq 'f') { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
57
|
14
|
|
|
|
|
4019
|
require Tie::File; |
|
58
|
14
|
|
|
|
|
94965
|
my @in; |
|
59
|
14
|
|
|
|
|
188
|
tie @in, "Tie::File", @_; |
|
60
|
14
|
|
|
|
|
3154
|
$args{in} = \@in; |
|
61
|
|
|
|
|
|
|
} elsif ($accepts eq 'c') { |
|
62
|
6
|
|
|
|
|
89
|
require Tie::Simple; |
|
63
|
6
|
|
|
|
|
26
|
my @in; |
|
64
|
|
|
|
|
|
|
my @els; |
|
65
|
6
|
|
|
|
|
24
|
my $elcount = 0; |
|
66
|
|
|
|
|
|
|
tie(@in, "Tie::Simple", undef, |
|
67
|
|
|
|
|
|
|
FETCHSIZE => sub { |
|
68
|
20
|
|
|
20
|
|
487
|
my $data = shift; # from Tie::Simple |
|
69
|
20
|
|
|
|
|
72
|
my @res = $icallback->(); |
|
70
|
20
|
|
|
|
|
182
|
$elcount += @res; |
|
71
|
20
|
|
|
|
|
102
|
push @els, @res; |
|
72
|
|
|
|
|
|
|
#say "D: res=[".join(",", @res), "], elcount=$elcount"; |
|
73
|
20
|
|
|
|
|
172
|
$elcount; |
|
74
|
|
|
|
|
|
|
}, |
|
75
|
|
|
|
|
|
|
FETCH => sub { |
|
76
|
15
|
|
|
15
|
|
196
|
my $data = shift; # from Tie::Simple |
|
77
|
15
|
|
|
|
|
95
|
shift @els; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
6
|
|
|
|
|
213
|
); |
|
80
|
6
|
|
|
|
|
137
|
$args{in} = \@in; |
|
81
|
|
|
|
|
|
|
} elsif ($accepts eq 'l') { |
|
82
|
15
|
|
|
|
|
49
|
$args{in} = \@_; |
|
83
|
|
|
|
|
|
|
} elsif ($accepts eq 'a') { |
|
84
|
16
|
|
|
|
|
57
|
$args{in} = $_[0]; |
|
85
|
|
|
|
|
|
|
} else { |
|
86
|
0
|
|
|
|
|
0
|
die "Invalid accepts, must be a|c|f|l"; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
51
|
100
|
|
|
|
204
|
if (ref($func) eq 'ARRAY') { |
|
90
|
10
|
|
|
|
|
30
|
$args{$_} = $func->[1]{$_} for grep {/\A\w+\z/} keys %{$func->[1]}; |
|
|
20
|
|
|
|
|
135
|
|
|
|
10
|
|
|
|
|
35
|
|
|
91
|
10
|
|
|
|
|
30
|
$func = $func->[0]; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
51
|
|
|
|
|
154
|
my $pkg = "Data::Unixish::$func"; |
|
95
|
51
|
100
|
|
|
|
309
|
load $pkg unless package_exists($pkg); |
|
96
|
51
|
|
|
|
|
1430
|
my $funcleaf = $func; $funcleaf =~ s/.+:://; |
|
|
51
|
|
|
|
|
156
|
|
|
97
|
51
|
|
|
|
|
176
|
my $funcname = "Data::Unixish::$func\::$funcleaf"; |
|
98
|
51
|
50
|
|
|
|
301
|
die "Subroutine &$funcname not defined" unless defined &$funcname; |
|
99
|
|
|
|
|
|
|
|
|
100
|
51
|
|
|
|
|
145
|
my @out; |
|
101
|
|
|
|
|
|
|
my $kidfh; |
|
102
|
51
|
|
|
|
|
0
|
my $pid; |
|
103
|
51
|
100
|
|
|
|
261
|
if ($returns eq 'c') { |
|
|
|
100
|
|
|
|
|
|
|
104
|
4
|
|
|
|
|
28
|
require Tie::Simple; |
|
105
|
|
|
|
|
|
|
tie @out, "Tie::Simple", undef, |
|
106
|
|
|
|
|
|
|
PUSH => sub { |
|
107
|
13
|
|
|
13
|
|
282
|
my $data = shift; # from Tie::Simple |
|
108
|
13
|
|
|
|
|
50
|
$ocallback->($_) for @_; |
|
109
|
4
|
|
|
|
|
44
|
}; |
|
110
|
4
|
|
|
|
|
44
|
$args{out} = \@out; |
|
111
|
|
|
|
|
|
|
} elsif ($returns eq 'f') { |
|
112
|
14
|
|
|
|
|
3055
|
require Tie::Simple; |
|
113
|
|
|
|
|
|
|
tie @out, "Tie::Simple", undef, |
|
114
|
|
|
|
|
|
|
PUSH => sub { |
|
115
|
13
|
|
|
13
|
|
587
|
my $data = shift; # from Tie::Simple |
|
116
|
13
|
|
|
|
|
91
|
for my $item (@_) { |
|
117
|
13
|
50
|
|
|
|
280
|
$item .= "\n" unless $item =~ /\n\z/; |
|
118
|
13
|
|
|
|
|
589
|
print STDOUT $item; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
14
|
|
|
|
|
47089
|
}; |
|
121
|
14
|
|
|
|
|
275
|
$args{out} = \@out; |
|
122
|
14
|
|
|
|
|
16117
|
$pid = open $kidfh, "-|"; |
|
123
|
14
|
50
|
|
|
|
1121
|
defined $pid or die "Can't fork: $!"; |
|
124
|
|
|
|
|
|
|
} else { |
|
125
|
33
|
|
|
|
|
100
|
$args{out} = \@out; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
51
|
100
|
|
|
|
333
|
unless ($pid) { |
|
129
|
46
|
|
|
46
|
|
330
|
no strict 'refs'; |
|
|
46
|
|
|
|
|
79
|
|
|
|
46
|
|
|
|
|
31229
|
|
|
130
|
41
|
|
|
|
|
876
|
my $res = $funcname->(%args); |
|
131
|
41
|
50
|
|
|
|
231
|
die "Dux function $funcname failed: $res->[0] - $res->[1]" |
|
132
|
|
|
|
|
|
|
unless $res->[0] == 200; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
51
|
100
|
|
|
|
782
|
if ($returns eq 'l') { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
136
|
16
|
100
|
|
|
|
58
|
if (wantarray) { |
|
137
|
11
|
|
|
|
|
350
|
return @out; |
|
138
|
|
|
|
|
|
|
} else { |
|
139
|
5
|
|
|
|
|
85
|
return $out[0]; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
} elsif ($returns eq 'a') { |
|
142
|
17
|
|
|
|
|
144
|
return \@out; |
|
143
|
|
|
|
|
|
|
} elsif ($returns eq 'c') { |
|
144
|
4
|
|
|
|
|
27
|
return; |
|
145
|
|
|
|
|
|
|
} elsif ($returns eq 'f') { |
|
146
|
14
|
100
|
|
|
|
230
|
if ($pid) { |
|
147
|
10
|
|
|
|
|
1341
|
return $kidfh; |
|
148
|
|
|
|
|
|
|
} else { |
|
149
|
4
|
|
|
|
|
308
|
exit; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
} else { |
|
152
|
0
|
|
|
|
|
0
|
die "Invalid returns, must be a|c|f|l"; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
5
|
|
|
5
|
1
|
9365
|
sub aduxa { _dux('a', 'a', @_) } |
|
157
|
2
|
|
|
2
|
1
|
894710
|
sub cduxa { _dux('c', 'a', @_) } |
|
158
|
5
|
|
|
5
|
1
|
13450
|
sub fduxa { _dux('f', 'a', @_) } |
|
159
|
5
|
|
|
5
|
1
|
26830
|
sub lduxa { _dux('l', 'a', @_) } |
|
160
|
|
|
|
|
|
|
|
|
161
|
1
|
|
|
1
|
1
|
3193
|
sub aduxc { _dux('a', 'c', @_) } |
|
162
|
1
|
|
|
1
|
1
|
719
|
sub cduxc { _dux('c', 'c', @_) } |
|
163
|
1
|
|
|
1
|
1
|
1506
|
sub fduxc { _dux('f', 'c', @_) } |
|
164
|
1
|
|
|
1
|
1
|
648
|
sub lduxc { _dux('l', 'c', @_) } |
|
165
|
|
|
|
|
|
|
|
|
166
|
5
|
|
|
5
|
1
|
14475
|
sub aduxf { _dux('a', 'f', @_) } |
|
167
|
2
|
|
|
2
|
1
|
3366
|
sub cduxf { _dux('c', 'f', @_) } |
|
168
|
3
|
|
|
3
|
1
|
1309749
|
sub fduxf { _dux('f', 'f', @_) } |
|
169
|
4
|
|
|
4
|
1
|
1724636
|
sub lduxf { _dux('l', 'f', @_) } |
|
170
|
|
|
|
|
|
|
|
|
171
|
5
|
|
|
5
|
1
|
25
|
sub aduxl { _dux('a', 'l', @_) } |
|
172
|
1
|
|
|
1
|
1
|
432238
|
sub cduxl { _dux('c', 'l', @_) } |
|
173
|
5
|
|
|
5
|
1
|
4770
|
sub fduxl { _dux('f', 'l', @_) } |
|
174
|
5
|
|
|
5
|
1
|
12735
|
sub lduxl { _dux('l', 'l', @_) } |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub _idux { |
|
177
|
55
|
|
|
55
|
|
120
|
my $accepts = shift; |
|
178
|
55
|
|
|
|
|
110
|
my $returns = shift; |
|
179
|
|
|
|
|
|
|
|
|
180
|
55
|
|
|
|
|
85
|
my $func = shift; |
|
181
|
|
|
|
|
|
|
|
|
182
|
55
|
|
|
|
|
119
|
my %args; |
|
183
|
|
|
|
|
|
|
my @items; |
|
184
|
|
|
|
|
|
|
|
|
185
|
55
|
100
|
|
|
|
231
|
if ($accepts eq 's') { |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
186
|
4
|
|
|
|
|
9
|
@items = ($_[0]); |
|
187
|
|
|
|
|
|
|
} elsif ($accepts eq 'a') { |
|
188
|
51
|
|
|
|
|
80
|
@items = @{ $_[0] }; |
|
|
51
|
|
|
|
|
164
|
|
|
189
|
|
|
|
|
|
|
} elsif ($accepts eq 'l') { |
|
190
|
0
|
|
|
|
|
0
|
@items = @_; |
|
191
|
|
|
|
|
|
|
} else { |
|
192
|
0
|
|
|
|
|
0
|
die "Invalid accepts, must be a|l|s"; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
|
|
195
|
55
|
100
|
|
|
|
270
|
if (ref($func) eq 'ARRAY') { |
|
196
|
51
|
|
|
|
|
94
|
$args{$_} = $func->[1]{$_} for keys %{$func->[1]}; |
|
|
51
|
|
|
|
|
292
|
|
|
197
|
51
|
|
|
|
|
233
|
$func = $func->[0]; |
|
198
|
|
|
|
|
|
|
} |
|
199
|
|
|
|
|
|
|
|
|
200
|
55
|
|
|
|
|
193
|
my $pkg = "Data::Unixish::$func"; |
|
201
|
55
|
100
|
|
|
|
223
|
load $pkg unless package_exists($pkg); |
|
202
|
55
|
|
|
|
|
1044
|
my $funcleaf = $func; $funcleaf =~ s/.+:://; |
|
|
55
|
|
|
|
|
204
|
|
|
203
|
55
|
|
|
|
|
155
|
my $funcname_i = "Data::Unixish::$func\::_${funcleaf}_item"; |
|
204
|
55
|
50
|
|
|
|
218
|
die "Subroutine &$funcname_i not defined" unless defined &$funcname_i; |
|
205
|
55
|
|
|
|
|
168
|
my $funcname_b = "Data::Unixish::$func\::_${funcleaf}_begin"; |
|
206
|
55
|
|
|
|
|
127
|
my $funcname_e = "Data::Unixish::$func\::_${funcleaf}_end"; |
|
207
|
|
|
|
|
|
|
|
|
208
|
55
|
|
|
|
|
97
|
my @res; |
|
209
|
|
|
|
|
|
|
{ |
|
210
|
46
|
|
|
46
|
|
322
|
no strict 'refs'; |
|
|
46
|
|
|
|
|
79
|
|
|
|
46
|
|
|
|
|
11122
|
|
|
|
55
|
|
|
|
|
79
|
|
|
211
|
55
|
100
|
|
|
|
73
|
my @bres; @bres = $funcname_b->(\%args) if defined &$funcname_b; |
|
|
55
|
|
|
|
|
305
|
|
|
212
|
55
|
|
|
|
|
141
|
for (@items) { |
|
213
|
225
|
|
|
|
|
612
|
push @res, $funcname_i->($_, \%args); |
|
214
|
|
|
|
|
|
|
} |
|
215
|
55
|
100
|
|
|
|
418
|
$funcname_e->(\%args, @bres) if defined &$funcname_e; |
|
216
|
|
|
|
|
|
|
} |
|
217
|
|
|
|
|
|
|
|
|
218
|
55
|
100
|
|
|
|
264
|
if ($returns eq 's') { |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
219
|
4
|
|
|
|
|
24
|
return $res[0]; |
|
220
|
|
|
|
|
|
|
} elsif ($returns eq 'l') { |
|
221
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
|
222
|
0
|
|
|
|
|
0
|
return @res; |
|
223
|
|
|
|
|
|
|
} else { |
|
224
|
0
|
|
|
|
|
0
|
return $res[0]; |
|
225
|
|
|
|
|
|
|
} |
|
226
|
|
|
|
|
|
|
} elsif ($returns eq 'a') { |
|
227
|
51
|
|
|
|
|
243
|
return \@res; |
|
228
|
|
|
|
|
|
|
} else { |
|
229
|
0
|
|
|
|
|
0
|
die "Invalid returns, must be a|l|s"; |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
|
|
233
|
4
|
|
|
4
|
1
|
39
|
sub siduxs { _idux('s', 's', @_) } |
|
234
|
|
|
|
|
|
|
|
|
235
|
51
|
|
|
51
|
1
|
206
|
sub aiduxa { _idux('a', 'a', @_) } |
|
236
|
0
|
|
|
0
|
1
|
|
sub aiduxl { _idux('a', 'l', @_) } |
|
237
|
|
|
|
|
|
|
|
|
238
|
0
|
|
|
0
|
1
|
|
sub liduxa { _idux('l', 'a', @_) } |
|
239
|
0
|
|
|
0
|
1
|
|
sub liduxl { _idux('l', 'l', @_) } |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
1; |
|
242
|
|
|
|
|
|
|
# ABSTRACT: Implementation for Unixish, a data transformation framework |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
__END__ |