use strict; use Text::CSV; my $csv = Text::CSV->new( { sep_char => "|", allow_whitespace => 1 } ); my $infile = "s.txt"; my $outfile = "s.csv"; open( my $fh, "<", $infile ); open( my $out, ">", $outfile ); while ( my $array = $csv->getline($fh) ) { local $" = ","; local $\ = "\n"; #$csv->combine(@{$array}); #my $line=$csv->string(); print $out "@{$array}"; #print $out $line; }