in reply to Text::CSV_XS and MySQL newline handling
You don't have to do as much as you think by way of doing reading and writing yourself, since Text:CSV_XS's getline returns an arrayref that you can manipulate.
# parse the row and handle any errors my $in_values = $parser->getline($in_fh); croak("Unable to parse line $line_num of file $file: " . $parser->error_input()) if !$in_values; #just add... for (@$in_values) { s:\\\\n:\n:gso }
With the addition of one line, you've unescaped your newlines. And, of course, to put them back, you'd reverse the substitution right before your $csv->print. Ideal? No. But it works, and the performance hit is negligible.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Text::CSV_XS and MySQL newline handling
by perrin (Chancellor) on Nov 17, 2005 at 20:52 UTC |