| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::LTSV::Liner; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
21323
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
60
|
|
|
4
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
67
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1313
|
use Term::ANSIColor; |
|
|
2
|
|
|
|
|
15600
|
|
|
|
2
|
|
|
|
|
1094
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = "0.04"; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
|
11
|
2
|
|
|
2
|
1
|
1052
|
my $class = shift; |
|
12
|
2
|
|
|
|
|
9
|
my %args = @_; |
|
13
|
2
|
50
|
|
|
|
7
|
unless ( $args{key} ) { |
|
14
|
2
|
|
|
|
|
4
|
$args{all} = 1; |
|
15
|
|
|
|
|
|
|
} |
|
16
|
2
|
|
|
|
|
6
|
bless \%args, $class; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub run { |
|
20
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
21
|
0
|
|
|
|
|
0
|
my $line = shift; |
|
22
|
0
|
|
|
|
|
0
|
chomp($line); |
|
23
|
0
|
|
|
|
|
0
|
print $self->parse($line) . "\n"; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub parse { |
|
27
|
2
|
|
|
2
|
1
|
9
|
my $self = shift; |
|
28
|
2
|
|
|
|
|
3
|
my $line = shift; |
|
29
|
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
3
|
my %wants; |
|
31
|
2
|
50
|
|
|
|
8
|
if ( $self->{key} ) { |
|
32
|
0
|
|
|
|
|
0
|
%wants = map { $_ => 1 } @{ $self->{key} }; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
5
|
my %stash; |
|
36
|
|
|
|
|
|
|
my @original; |
|
37
|
2
|
|
|
|
|
8
|
for my $kv ( map { [ split( /:/, $_, 2 ) ] } split( /\t/, $line ) ) { |
|
|
6
|
|
|
|
|
20
|
|
|
38
|
6
|
0
|
33
|
|
|
15
|
next if ( not $self->{all} and not $wants{ $kv->[0] } ); |
|
39
|
6
|
|
|
|
|
12
|
$stash{ $kv->[0] } = $kv->[1]; |
|
40
|
6
|
|
|
|
|
13
|
push( @original, $kv->[0] ); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
5
|
my @out; |
|
44
|
2
|
50
|
|
|
|
8
|
my @ordered = $self->{key} ? @{ $self->{key} } : @original; |
|
|
0
|
|
|
|
|
0
|
|
|
45
|
2
|
|
|
|
|
3
|
for my $_key (@ordered) { |
|
46
|
6
|
|
50
|
|
|
17
|
my ( $key, $value ) = ( $_key, $stash{$_key} || q{} ); |
|
47
|
6
|
50
|
|
|
|
16
|
if ( not $self->{'no-color'} ) { |
|
48
|
0
|
|
|
|
|
0
|
$key = color('green') . $key . color('reset'); |
|
49
|
0
|
|
|
|
|
0
|
$value = color('magenta') . $value . color('reset'); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
6
|
100
|
|
|
|
10
|
if ($self->{'no-key'}) { |
|
52
|
3
|
|
|
|
|
7
|
push(@out, $value); |
|
53
|
|
|
|
|
|
|
} else { |
|
54
|
3
|
|
|
|
|
8
|
push(@out, join(q{:}, $key, $value)); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
9
|
return join( "\t", @out ); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
|
62
|
|
|
|
|
|
|
__END__ |