line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Reader class for YAML::PP representing input data |
2
|
42
|
|
|
42
|
|
300
|
use strict; |
|
42
|
|
|
|
|
99
|
|
|
42
|
|
|
|
|
1312
|
|
3
|
42
|
|
|
42
|
|
225
|
use warnings; |
|
42
|
|
|
|
|
93
|
|
|
42
|
|
|
|
|
15325
|
|
4
|
|
|
|
|
|
|
package YAML::PP::Reader; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.036_002'; # TRIAL VERSION |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
0
|
9
|
sub input { return $_[0]->{input} } |
9
|
0
|
|
|
0
|
0
|
0
|
sub set_input { $_[0]->{input} = $_[1] } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
12229
|
|
|
12229
|
0
|
25625
|
my ($class, %args) = @_; |
13
|
12229
|
|
|
|
|
20996
|
my $input = delete $args{input}; |
14
|
12229
|
|
|
|
|
53339
|
return bless { |
15
|
|
|
|
|
|
|
input => $input, |
16
|
|
|
|
|
|
|
}, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub read { |
20
|
1
|
|
|
1
|
0
|
3
|
my ($self) = @_; |
21
|
1
|
|
50
|
|
|
5
|
my $pos = pos $self->{input} || 0; |
22
|
1
|
|
|
|
|
4
|
my $yaml = substr($self->{input}, $pos); |
23
|
1
|
|
|
|
|
4
|
$self->{input} = ''; |
24
|
1
|
|
|
|
|
11
|
return $yaml; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub readline { |
28
|
40032
|
|
|
40032
|
0
|
64069
|
my ($self) = @_; |
29
|
40032
|
100
|
|
|
|
103109
|
unless (length $self->{input}) { |
30
|
4427
|
|
|
|
|
9624
|
return; |
31
|
|
|
|
|
|
|
} |
32
|
35605
|
50
|
|
|
|
173794
|
if ( $self->{input} =~ m/\G([^\r\n]*(?:\n|\r\n|\r|\z))/g ) { |
33
|
35605
|
|
|
|
|
90332
|
my $line = $1; |
34
|
35605
|
100
|
|
|
|
80348
|
unless (length $line) { |
35
|
7355
|
|
|
|
|
14660
|
$self->{input} = ''; |
36
|
7355
|
|
|
|
|
19724
|
return; |
37
|
|
|
|
|
|
|
} |
38
|
28250
|
|
|
|
|
85464
|
return $line; |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
0
|
return; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
package YAML::PP::Reader::File; |
44
|
|
|
|
|
|
|
|
45
|
42
|
|
|
42
|
|
394
|
use Scalar::Util qw/ openhandle /; |
|
42
|
|
|
|
|
94
|
|
|
42
|
|
|
|
|
3228
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
our @ISA = qw/ YAML::PP::Reader /; |
48
|
|
|
|
|
|
|
|
49
|
42
|
|
|
42
|
|
404
|
use Carp qw/ croak /; |
|
42
|
|
|
|
|
114
|
|
|
42
|
|
|
|
|
16505
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub open_handle { |
52
|
19
|
100
|
|
19
|
|
82
|
if (openhandle( $_[0]->{input} )) { |
53
|
1
|
|
|
|
|
4
|
return $_[0]->{input}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
open my $fh, '<:encoding(UTF-8)', $_[0]->{input} |
56
|
18
|
50
|
|
4
|
|
888
|
or croak "Could not open '$_[0]->{input}' for reading: $!"; |
|
4
|
|
|
|
|
37
|
|
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
38
|
|
57
|
18
|
|
|
|
|
50198
|
return $fh; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub read { |
61
|
0
|
|
0
|
0
|
|
0
|
my $fh = $_[0]->{filehandle} ||= $_[0]->open_handle; |
62
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
63
|
0
|
|
|
|
|
0
|
my @yaml = <$fh>; |
64
|
0
|
|
|
|
|
0
|
return @yaml; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else { |
67
|
0
|
|
|
|
|
0
|
local $/; |
68
|
0
|
|
|
|
|
0
|
my $yaml = <$fh>; |
69
|
0
|
|
|
|
|
0
|
return $yaml; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub readline { |
74
|
974
|
|
66
|
974
|
|
2157
|
my $fh = $_[0]->{filehandle} ||= $_[0]->open_handle; |
75
|
974
|
|
|
|
|
5377
|
return scalar <$fh>; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |