common/tools/lib/auto/Text/CSV/combine.al
changeset 89 a8aa5d600806
equal deleted inserted replaced
88:28463bb10fde 89:a8aa5d600806
       
     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 125 "blib\lib\Text\CSV.pm (autosplit into blib\lib\auto/Text\CSV/combine.al)"
       
     7 ################################################################################
       
     8 # combine
       
     9 #
       
    10 #    object method returning success or failure.  the given arguments are
       
    11 #    combined into a single comma-separated value.  failure can be the result of
       
    12 #    no arguments or an argument containing an invalid character.   side-effects
       
    13 #    include:
       
    14 #      setting status()
       
    15 #      setting fields()
       
    16 #      setting string()
       
    17 #      setting error_input()
       
    18 ################################################################################
       
    19 sub combine {
       
    20   my $self = shift;
       
    21   my @part = @_;
       
    22   $self->{'_FIELDS'} = \@part;
       
    23   $self->{'_ERROR_INPUT'} = undef;
       
    24   $self->{'_STATUS'} = 0;
       
    25   $self->{'_STRING'} = '';
       
    26   my $column = '';
       
    27   my $combination = '';
       
    28   my $skip_comma = 1;
       
    29   if ($#part >= 0) {
       
    30 
       
    31     # at least one argument was given for "combining"...
       
    32     for $column (@part) {
       
    33       if ($column =~ /[^\t\040-\176]/) {
       
    34 
       
    35 	# an argument contained an invalid character...
       
    36 	$self->{'_ERROR_INPUT'} = $column;
       
    37 	return $self->{'_STATUS'};
       
    38       }
       
    39       if ($skip_comma) {
       
    40 
       
    41 	# do not put a comma before the first argument...
       
    42 	$skip_comma = 0;
       
    43       } else {
       
    44 
       
    45 	# do put a comma before all arguments except the first argument...
       
    46 	$combination .= ',';
       
    47       }
       
    48       $column =~ s/\042/\042\042/go;
       
    49       $combination .= "\042";
       
    50       $combination .= $column;
       
    51       $combination .= "\042";
       
    52     }
       
    53     $self->{'_STRING'} = $combination;
       
    54     $self->{'_STATUS'} = 1;
       
    55   }
       
    56   return $self->{'_STATUS'};
       
    57 }
       
    58 
       
    59 # end of Text::CSV::combine
       
    60 1;