line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Spreadsheet::Write::WriteCSV; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
14
|
use 5.008; |
|
1
|
|
|
|
|
2
|
|
4
|
1
|
|
|
1
|
|
5
|
use base qw'Spreadsheet::Write'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
78
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Text::CSV 1.18; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
220
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
2
|
|
|
2
|
1
|
5
|
my ($class, %args) = @_; |
10
|
2
|
|
|
|
|
5
|
my $self = bless {}, $class; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
0
|
|
|
6
|
my $filename = $args{'file'} || $args{'filename'} || die "Need filename."; |
13
|
2
|
|
|
|
|
4
|
$self->{'_FILENAME'} = $filename; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
50
|
|
|
8
|
$args{'csv_options'}->{'sep_char'} ||= ","; |
16
|
2
|
|
33
|
|
|
8
|
$args{'csv_options'}->{'eol'} ||= $/; |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
3
|
$self->{'_CSV_OPTIONS'} = $args{'csv_options'}; |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
10
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _prepare { |
24
|
6
|
|
|
6
|
|
6
|
my $self = shift; |
25
|
6
|
|
66
|
|
|
19
|
$self->{'_CSV_OBJ'}||=Text::CSV->new($self->{'_CSV_OPTIONS'}); |
26
|
6
|
|
|
|
|
219
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub close { |
30
|
4
|
|
|
4
|
1
|
7
|
my $self=shift; |
31
|
4
|
100
|
|
|
|
25
|
return if $self->{'_CLOSED'}; |
32
|
2
|
50
|
|
|
|
7
|
$self->{'_FH'}->close if $self->{'_FH'}; |
33
|
2
|
|
|
|
|
107
|
$self->{'_CLOSED'}=1; |
34
|
2
|
|
|
|
|
5
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _add_prepared_row { |
38
|
6
|
|
|
6
|
|
7
|
my $self = shift; |
39
|
|
|
|
|
|
|
|
40
|
6
|
|
|
|
|
5
|
my @texts; |
41
|
6
|
|
|
|
|
6
|
foreach (@_) { |
42
|
24
|
|
|
|
|
22
|
my $content = $_->{'content'}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$content = sprintf($content, $_->{'sprintf'}) |
45
|
24
|
50
|
|
|
|
27
|
if $_->{'sprintf'}; |
46
|
|
|
|
|
|
|
|
47
|
24
|
|
|
|
|
24
|
push @texts, $content; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$self->{'_CSV_OBJ'}->print($self->{'_FH'},\@texts) || |
51
|
6
|
50
|
|
|
|
43
|
die "csv_combine failed at ".$self->{'_CSV_OBJ'}->error_input(); |
52
|
|
|
|
|
|
|
|
53
|
6
|
|
|
|
|
66
|
return $self; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
############################################################################### |
57
|
|
|
|
|
|
|
1; |