line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
35
|
|
|
35
|
|
252
|
use strict; |
|
35
|
|
|
|
|
85
|
|
|
35
|
|
|
|
|
1005
|
|
2
|
35
|
|
|
35
|
|
188
|
use warnings; |
|
35
|
|
|
|
|
81
|
|
|
35
|
|
|
|
|
1764
|
|
3
|
|
|
|
|
|
|
package YAML::PP::Writer::File; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.036'; # VERSION |
6
|
|
|
|
|
|
|
|
7
|
35
|
|
|
35
|
|
250
|
use Scalar::Util qw/ openhandle /; |
|
35
|
|
|
|
|
83
|
|
|
35
|
|
|
|
|
2075
|
|
8
|
|
|
|
|
|
|
|
9
|
35
|
|
|
35
|
|
234
|
use base qw/ YAML::PP::Writer /; |
|
35
|
|
|
|
|
98
|
|
|
35
|
|
|
|
|
4845
|
|
10
|
|
|
|
|
|
|
|
11
|
35
|
|
|
35
|
|
263
|
use Carp qw/ croak /; |
|
35
|
|
|
|
|
107
|
|
|
35
|
|
|
|
|
10783
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _open_handle { |
14
|
6
|
|
|
6
|
|
12
|
my ($self) = @_; |
15
|
6
|
100
|
|
|
|
24
|
if (openhandle($self->{output})) { |
16
|
1
|
|
|
|
|
3
|
$self->{filehandle} = $self->{output}; |
17
|
1
|
|
|
|
|
3
|
return $self->{output}; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
open my $fh, '>:encoding(UTF-8)', $self->{output} |
20
|
5
|
100
|
|
|
|
1142
|
or croak "Could not open '$self->{output}' for writing: $!"; |
21
|
4
|
|
|
|
|
359
|
$self->{filehandle} = $fh; |
22
|
4
|
|
|
|
|
19
|
return $fh; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub write { |
26
|
30
|
|
|
30
|
1
|
58
|
my ($self, $line) = @_; |
27
|
30
|
|
|
|
|
54
|
my $fh = $self->{filehandle}; |
28
|
30
|
|
|
|
|
128
|
print $fh $line; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub init { |
32
|
6
|
|
|
6
|
1
|
14
|
my ($self) = @_; |
33
|
6
|
|
|
|
|
23
|
my $fh = $self->_open_handle; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub finish { |
37
|
5
|
|
|
5
|
1
|
14
|
my ($self) = @_; |
38
|
5
|
100
|
|
|
|
22
|
if (openhandle($self->{output})) { |
39
|
|
|
|
|
|
|
# Original argument was a file handle, so the caller needs |
40
|
|
|
|
|
|
|
# to close it |
41
|
1
|
|
|
|
|
2
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
4
|
|
|
|
|
629
|
close $self->{filehandle}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |