line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Unixish::head; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
440
|
use 5.010; |
|
1
|
|
|
|
|
6
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
325
|
use syntax 'each_on_array'; # to support perl < 5.12 |
|
1
|
|
|
|
|
20005
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
2975
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
22
|
|
7
|
|
|
|
|
|
|
#use Log::Any '$log'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
400
|
use Data::Unixish::Util qw(%common_args); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
227
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.570'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %SPEC; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$SPEC{head} = { |
16
|
|
|
|
|
|
|
v => 1.1, |
17
|
|
|
|
|
|
|
summary => 'Output the first items of data', |
18
|
|
|
|
|
|
|
args => { |
19
|
|
|
|
|
|
|
%common_args, |
20
|
|
|
|
|
|
|
items => { |
21
|
|
|
|
|
|
|
summary => 'Number of items to output', |
22
|
|
|
|
|
|
|
schema=>['int*' => {default=>10}], |
23
|
|
|
|
|
|
|
tags => ['main'], |
24
|
|
|
|
|
|
|
cmdline_aliases => { n=>{} }, |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
tags => [qw/filtering/], |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
sub head { |
30
|
4
|
|
|
4
|
1
|
14
|
my %args = @_; |
31
|
4
|
|
|
|
|
8
|
my ($in, $out) = ($args{in}, $args{out}); |
32
|
4
|
|
100
|
|
|
14
|
my $n = $args{items} // 10; |
33
|
|
|
|
|
|
|
|
34
|
4
|
|
|
|
|
20
|
while (my ($index, $item) = each @$in) { |
35
|
17
|
100
|
|
|
|
28
|
last if $index >= $n; |
36
|
13
|
|
|
|
|
28
|
push @$out, $item; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
4
|
|
|
|
|
13
|
[200, "OK"]; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
# ABSTRACT: Output the first items of data |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |