line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::DSV; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
78008
|
use strict; |
|
7
|
|
|
|
|
46
|
|
|
7
|
|
|
|
|
187
|
|
4
|
7
|
|
|
7
|
|
34
|
use warnings; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
3792
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.11; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Constructor. |
9
|
|
|
|
|
|
|
sub new { |
10
|
5
|
|
|
5
|
1
|
404
|
my ($class, @params) = @_; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Create object. |
13
|
5
|
|
|
|
|
17
|
my $self = bless {}, $class; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Object. |
16
|
5
|
|
|
|
|
14
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Parse all data. |
20
|
|
|
|
|
|
|
sub parse { |
21
|
5
|
|
|
5
|
1
|
4361
|
my ($self, $data) = @_; |
22
|
5
|
|
|
|
|
9
|
my @data_lines; |
23
|
5
|
|
|
|
|
19
|
foreach my $line (split m/\n/ms, $data) { |
24
|
14
|
100
|
100
|
|
|
76
|
if ($line =~ m/^\s*$/ms || $line =~ m/^\s*#/) { |
25
|
4
|
|
|
|
|
9
|
next; |
26
|
|
|
|
|
|
|
} |
27
|
10
|
|
|
|
|
21
|
push @data_lines, [$self->parse_line($line)]; |
28
|
|
|
|
|
|
|
} |
29
|
5
|
|
|
|
|
20
|
return @data_lines; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Parse one line. |
33
|
|
|
|
|
|
|
sub parse_line { |
34
|
16
|
|
|
16
|
1
|
2956
|
my ($self, $line) = @_; |
35
|
16
|
|
|
|
|
76
|
my @data_line = split m/(?
|
36
|
16
|
|
|
|
|
35
|
foreach my $data (@data_line) { |
37
|
43
|
|
|
|
|
62
|
$data =~ s/\\:/:/gms; |
38
|
43
|
|
|
|
|
61
|
$data =~ s/\\n/\n/gms; |
39
|
|
|
|
|
|
|
} |
40
|
16
|
|
|
|
|
60
|
return @data_line; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Serialize all data. |
44
|
|
|
|
|
|
|
sub serialize { |
45
|
1
|
|
|
1
|
1
|
9
|
my ($self, @data_lines) = @_; |
46
|
1
|
|
|
|
|
2
|
my $ret; |
47
|
1
|
|
|
|
|
3
|
foreach my $data_line_ar (@data_lines) { |
48
|
2
|
|
|
|
|
2
|
$ret .= $self->serialize_line(@{$data_line_ar})."\n"; |
|
2
|
|
|
|
|
7
|
|
49
|
|
|
|
|
|
|
} |
50
|
1
|
|
|
|
|
10
|
return $ret; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Serialize one line. |
54
|
|
|
|
|
|
|
sub serialize_line { |
55
|
8
|
|
|
8
|
1
|
2396
|
my ($self, @data_line) = @_; |
56
|
8
|
|
|
|
|
16
|
my @escape_data = @data_line; |
57
|
8
|
|
|
|
|
11
|
foreach my $data (@escape_data) { |
58
|
19
|
|
|
|
|
37
|
$data =~ s/:/\\:/gms; |
59
|
19
|
|
|
|
|
30
|
$data =~ s/\n/\\n/gms; |
60
|
|
|
|
|
|
|
} |
61
|
8
|
|
|
|
|
30
|
return join ':', @escape_data; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |