line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Thesaurus::CSV; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
17264
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
593
|
use Thesaurus; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
31
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
11
|
use base 'Thesaurus'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
94
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
816
|
use IO::File; |
|
1
|
|
|
|
|
1054
|
|
|
1
|
|
|
|
|
191
|
|
10
|
1
|
|
|
1
|
|
10
|
use Params::Validate qw( validate SCALAR BOOLEAN ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
59
|
|
11
|
1
|
|
|
1
|
|
7
|
use Text::CSV_XS; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
430
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new |
14
|
|
|
|
|
|
|
{ |
15
|
4
|
|
|
4
|
1
|
4382
|
return shift->SUPER::new(@_); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _init |
19
|
|
|
|
|
|
|
{ |
20
|
4
|
|
|
4
|
|
9
|
my $self = shift; |
21
|
4
|
|
|
|
|
74
|
my %p = validate( @_, |
22
|
|
|
|
|
|
|
{ filename => { type => SCALAR } } |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
49
|
$self->{csv} = Text::CSV_XS->new( { binary => 1 } ); |
26
|
4
|
|
|
|
|
528
|
$self->{params}{filename} = $p{filename}; |
27
|
|
|
|
|
|
|
|
28
|
4
|
100
|
|
|
|
141
|
if ( -e $self->{params}{filename} ) |
29
|
|
|
|
|
|
|
{ |
30
|
1
|
50
|
|
|
|
10
|
my $fh = IO::File->new("<$self->{params}{filename}") |
31
|
|
|
|
|
|
|
or die "Cannot read $self->{params}{filename}: $!"; |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
87
|
while ( ! $fh->eof ) |
34
|
|
|
|
|
|
|
{ |
35
|
2
|
|
|
|
|
117
|
my $cols = $self->{csv}->getline($fh); |
36
|
|
|
|
|
|
|
|
37
|
2
|
50
|
|
|
|
93
|
die "Text::CSV_XS can't parse " . $self->{csv}->error_input |
38
|
|
|
|
|
|
|
unless defined $cols; |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
9
|
$self->add($cols); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
4
|
|
|
|
|
38
|
return $self; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub save |
48
|
|
|
|
|
|
|
{ |
49
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
1
|
50
|
|
|
|
9
|
my $fh = IO::File->new(">$self->{params}{filename}") |
52
|
|
|
|
|
|
|
or die "Cannot write to $self->{params}{filename}: $!"; |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
218
|
foreach my $list ( $self->all ) |
55
|
|
|
|
|
|
|
{ |
56
|
1
|
|
|
1
|
|
12
|
$self->{csv}->print( $fh, $list ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
66
|
|
57
|
2
|
|
|
|
|
21
|
print $fh "\n"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
63
|
close $fh; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |