line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
93738
|
use utf8; |
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
6
|
|
2
|
1
|
|
|
1
|
|
42
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
3
|
|
|
|
|
|
|
package Text::Continuation::Parser; |
4
|
|
|
|
|
|
|
our $VERSION = '0.4'; # TRIAL |
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
6
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
7
|
1
|
|
|
1
|
|
5
|
use Carp qw(croak); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
62
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Parse files with continuation lines |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
7
|
use base qw(Exporter); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
671
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw(parse_line); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $trim = qr/(?:^\s*|\s*$)/; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub parse_line { |
18
|
17
|
|
|
17
|
1
|
16661
|
my ($fh, $line) = @_; |
19
|
|
|
|
|
|
|
|
20
|
17
|
|
|
|
|
312
|
my $new = $fh->getline; |
21
|
|
|
|
|
|
|
|
22
|
17
|
100
|
100
|
|
|
888
|
if ($line && !defined $new) { |
23
|
1
|
|
|
|
|
10
|
croak |
24
|
|
|
|
|
|
|
"Line continuation detected and reaching end of file. This is invalid"; |
25
|
|
|
|
|
|
|
} |
26
|
16
|
100
|
|
|
|
34
|
return unless defined $new; |
27
|
|
|
|
|
|
|
|
28
|
15
|
|
|
|
|
29
|
chomp($new); |
29
|
15
|
|
|
|
|
34
|
$new =~ s/\r//g; |
30
|
15
|
100
|
|
|
|
91
|
if ($new =~ /^\s*#/) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
31
|
1
|
50
|
50
|
|
|
8
|
if (length($line//'')) { |
32
|
1
|
|
|
|
|
4
|
return parse_line($fh, $line); |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
0
|
return $new; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
elsif ($new =~ /^\\$/) { |
37
|
1
|
|
|
|
|
20
|
return parse_line($fh, $line); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
elsif ($new =~ /\s+\\\s*$/) { |
40
|
3
|
|
|
|
|
30
|
$new =~ s#\s+\\\s*$##; |
41
|
3
|
|
|
|
|
29
|
$new =~ s/$trim//g; |
42
|
3
|
100
|
100
|
|
|
15
|
if (length($line//'')) { |
43
|
2
|
50
|
|
|
|
12
|
if (length($new)) { |
44
|
2
|
|
|
|
|
14
|
return parse_line($fh, join(' ', $line, $new)); |
45
|
|
|
|
|
|
|
} |
46
|
0
|
|
|
|
|
0
|
return parse_line($fh, $line); |
47
|
|
|
|
|
|
|
} |
48
|
1
|
50
|
|
|
|
8
|
return parse_line($fh, length($new) ? $new : undef); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
elsif ($new =~ /\S+\\\s*$/) { |
51
|
5
|
|
|
|
|
22
|
$new =~ s#\\\s*$##; |
52
|
5
|
|
|
|
|
33
|
$new =~ s/$trim//g; |
53
|
5
|
100
|
100
|
|
|
28
|
if (length($line//'')) { |
54
|
2
|
50
|
|
|
|
6
|
if (length($new)) { |
55
|
2
|
|
|
|
|
11
|
return parse_line($fh, join('', $line, $new)); |
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
|
|
0
|
return parse_line($fh, $line); |
58
|
|
|
|
|
|
|
} |
59
|
3
|
50
|
|
|
|
15
|
return parse_line($fh, length($new) ? $new : undef); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
elsif ($new =~ /^\s+/) { |
62
|
0
|
|
|
|
|
0
|
$new =~ s/$trim//g; |
63
|
0
|
0
|
0
|
|
|
0
|
if (!length($new) && length($line//'')) { |
|
|
|
0
|
|
|
|
|
64
|
0
|
|
|
|
|
0
|
croak |
65
|
|
|
|
|
|
|
"Line continuation detected and empty line. This is invalid"; |
66
|
|
|
|
|
|
|
} |
67
|
0
|
0
|
0
|
|
|
0
|
if (length($line//'')) { |
68
|
0
|
0
|
|
|
|
0
|
return length($new) ? join(' ', $line, $new) : $line; |
69
|
|
|
|
|
|
|
} |
70
|
0
|
|
|
|
|
0
|
return $new; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
5
|
|
|
|
|
36
|
$new =~ s/$trim//g; |
74
|
5
|
100
|
50
|
|
|
23
|
if (!length($new) && length($line//'')) { |
|
|
|
66
|
|
|
|
|
75
|
1
|
|
|
|
|
22
|
croak |
76
|
|
|
|
|
|
|
"Line continuation detected and empty line. This is invalid"; |
77
|
|
|
|
|
|
|
} |
78
|
4
|
100
|
100
|
|
|
30
|
return length($line//'') ? join('', $line, $new) : $new; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |