equal
deleted
inserted
replaced
|
1 # NOTE: Derived from blib\lib\Text\CSV.pm. |
|
2 # Changes made here will be lost when autosplit again. |
|
3 # See AutoSplit.pm. |
|
4 package Text::CSV; |
|
5 |
|
6 #line 177 "blib\lib\Text\CSV.pm (autosplit into blib\lib\auto/Text\CSV/parse.al)" |
|
7 ################################################################################ |
|
8 # parse |
|
9 # |
|
10 # object method returning success or failure. the given argument is expected |
|
11 # to be a valid comma-separated value. failure can be the result of |
|
12 # no arguments or an argument containing an invalid sequence of characters. |
|
13 # side-effects include: |
|
14 # setting status() |
|
15 # setting fields() |
|
16 # setting string() |
|
17 # setting error_input() |
|
18 ################################################################################ |
|
19 sub parse { |
|
20 my $self = shift; |
|
21 $self->{'_STRING'} = shift; |
|
22 $self->{'_FIELDS'} = undef; |
|
23 $self->{'_ERROR_INPUT'} = $self->{'_STRING'}; |
|
24 $self->{'_STATUS'} = 0; |
|
25 if (!defined($self->{'_STRING'})) { |
|
26 return $self->{'_STATUS'}; |
|
27 } |
|
28 my $keep_biting = 1; |
|
29 my $palatable = 0; |
|
30 my $line = $self->{'_STRING'}; |
|
31 if ($line =~ /\n$/) { |
|
32 chop($line); |
|
33 if ($line =~ /\r$/) { |
|
34 chop($line); |
|
35 } |
|
36 } |
|
37 my $mouthful = ''; |
|
38 my @part = (); |
|
39 while ($keep_biting and ($palatable = $self->_bite(\$line, \$mouthful, \$keep_biting))) { |
|
40 push(@part, $mouthful); |
|
41 } |
|
42 if ($palatable) { |
|
43 $self->{'_ERROR_INPUT'} = undef; |
|
44 $self->{'_FIELDS'} = \@part; |
|
45 } |
|
46 return $self->{'_STATUS'} = $palatable; |
|
47 } |
|
48 |
|
49 # end of Text::CSV::parse |
|
50 1; |