line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::CSV; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
31
|
|
|
31
|
|
2303709
|
use strict; |
|
31
|
|
|
|
|
358
|
|
|
31
|
|
|
|
|
990
|
|
5
|
31
|
|
|
31
|
|
177
|
use Exporter; |
|
31
|
|
|
|
|
54
|
|
|
31
|
|
|
|
|
1214
|
|
6
|
31
|
|
|
31
|
|
180
|
use Carp (); |
|
31
|
|
|
|
|
55
|
|
|
31
|
|
|
|
|
950
|
|
7
|
31
|
|
|
31
|
|
196
|
use vars qw( $VERSION $DEBUG @ISA @EXPORT_OK ); |
|
31
|
|
|
|
|
77
|
|
|
31
|
|
|
|
|
3677
|
|
8
|
|
|
|
|
|
|
@ISA = qw( Exporter ); |
9
|
|
|
|
|
|
|
@EXPORT_OK = qw( csv ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
BEGIN { |
12
|
31
|
|
|
31
|
|
131
|
$VERSION = '2.01'; |
13
|
31
|
|
|
|
|
20040
|
$DEBUG = 0; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# if use CSV_XS, requires version |
17
|
|
|
|
|
|
|
my $Module_XS = 'Text::CSV_XS'; |
18
|
|
|
|
|
|
|
my $Module_PP = 'Text::CSV_PP'; |
19
|
|
|
|
|
|
|
my $XS_Version = '1.46'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $Is_Dynamic = 0; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my @PublicMethods = qw/ |
24
|
|
|
|
|
|
|
version error_diag error_input |
25
|
|
|
|
|
|
|
known_attributes csv |
26
|
|
|
|
|
|
|
PV IV NV |
27
|
|
|
|
|
|
|
/; |
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Check the environment variable to decide worker module. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
unless ($Text::CSV::Worker) { |
33
|
|
|
|
|
|
|
$Text::CSV::DEBUG and Carp::carp("Check used worker module..."); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
if ( exists $ENV{PERL_TEXT_CSV} ) { |
36
|
|
|
|
|
|
|
if ($ENV{PERL_TEXT_CSV} eq '0' or $ENV{PERL_TEXT_CSV} eq 'Text::CSV_PP') { |
37
|
|
|
|
|
|
|
_load_pp() or Carp::croak $@; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
elsif ($ENV{PERL_TEXT_CSV} eq '1' or $ENV{PERL_TEXT_CSV} =~ /Text::CSV_XS\s*,\s*Text::CSV_PP/) { |
40
|
|
|
|
|
|
|
_load_xs() or _load_pp() or Carp::croak $@; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif ($ENV{PERL_TEXT_CSV} eq '2' or $ENV{PERL_TEXT_CSV} eq 'Text::CSV_XS') { |
43
|
|
|
|
|
|
|
_load_xs() or Carp::croak $@; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else { |
46
|
|
|
|
|
|
|
Carp::croak "The value of environmental variable 'PERL_TEXT_CSV' is invalid."; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
|
|
|
|
|
|
_load_xs() or _load_pp() or Carp::croak $@; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub new { # normal mode |
56
|
627
|
|
|
627
|
1
|
617482
|
my $proto = shift; |
57
|
627
|
|
100
|
|
|
3230
|
my $class = ref($proto) || $proto; |
58
|
|
|
|
|
|
|
|
59
|
627
|
100
|
|
|
|
1554
|
unless ( $proto ) { # for Text::CSV_XS/PP::new(0); |
60
|
1
|
|
|
|
|
63
|
return eval qq| $Text::CSV::Worker\::new( \$proto ) |; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#if (ref $_[0] and $_[0]->{module}) { |
64
|
|
|
|
|
|
|
# Carp::croak("Can't set 'module' in non dynamic mode."); |
65
|
|
|
|
|
|
|
#} |
66
|
|
|
|
|
|
|
|
67
|
626
|
100
|
|
|
|
3053
|
if ( my $obj = $Text::CSV::Worker->new(@_) ) { |
68
|
575
|
|
|
|
|
1257
|
$obj->{_MODULE} = $Text::CSV::Worker; |
69
|
575
|
|
|
|
|
1088
|
bless $obj, $class; |
70
|
575
|
|
|
|
|
4732
|
return $obj; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
50
|
|
|
|
|
157
|
return; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
0
|
0
|
0
|
sub require_xs_version { $XS_Version; } |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub module { |
84
|
2
|
|
|
2
|
0
|
4
|
my $proto = shift; |
85
|
|
|
|
|
|
|
return !ref($proto) ? $Text::CSV::Worker |
86
|
2
|
50
|
|
|
|
15
|
: ref($proto->{_MODULE}) ? ref($proto->{_MODULE}) : $proto->{_MODULE}; |
|
|
50
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
*backend = *module; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub is_xs { |
93
|
0
|
|
|
0
|
1
|
0
|
return $_[0]->module eq $Module_XS; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub is_pp { |
98
|
1
|
|
|
1
|
1
|
4
|
return $_[0]->module eq $Module_PP; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
0
|
0
|
0
|
sub is_dynamic { $Is_Dynamic; } |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
0
|
|
0
|
sub _load_xs { _load($Module_XS, $XS_Version) } |
105
|
|
|
|
|
|
|
|
106
|
31
|
|
|
31
|
|
85
|
sub _load_pp { _load($Module_PP) } |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _load { |
109
|
31
|
|
|
31
|
|
74
|
my ($module, $version) = @_; |
110
|
31
|
|
50
|
|
|
221
|
$version ||= ''; |
111
|
|
|
|
|
|
|
|
112
|
31
|
50
|
|
|
|
75
|
$Text::CSV::DEBUG and Carp::carp "Load $module."; |
113
|
|
|
|
|
|
|
|
114
|
31
|
|
|
31
|
|
34578
|
eval qq| use $module $version |; |
|
31
|
|
|
|
|
117
|
|
|
31
|
|
|
|
|
1390
|
|
|
31
|
|
|
|
|
2273
|
|
115
|
|
|
|
|
|
|
|
116
|
31
|
50
|
|
|
|
212
|
return if $@; |
117
|
|
|
|
|
|
|
|
118
|
31
|
|
|
|
|
422
|
push @Text::CSV::ISA, $module; |
119
|
31
|
|
|
|
|
116
|
$Text::CSV::Worker = $module; |
120
|
|
|
|
|
|
|
|
121
|
31
|
|
|
|
|
426
|
local $^W; |
122
|
31
|
|
|
31
|
|
259
|
no strict qw(refs); |
|
31
|
|
|
|
|
100
|
|
|
31
|
|
|
|
|
4587
|
|
123
|
|
|
|
|
|
|
|
124
|
31
|
|
|
|
|
123
|
for my $method (@PublicMethods) { |
125
|
248
|
|
|
|
|
372
|
*{"Text::CSV::$method"} = \&{"$module\::$method"}; |
|
248
|
|
|
|
|
1058
|
|
|
248
|
|
|
|
|
660
|
|
126
|
|
|
|
|
|
|
} |
127
|
31
|
|
|
|
|
274
|
return 1; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |
133
|
|
|
|
|
|
|
__END__ |