[Chicago-talk] Removing Characters

Ted Zlatanov tzz at lifelogs.com
Mon Oct 22 08:29:39 PDT 2007

On Mon, 22 Oct 2007 07:52:33 -0700 (PDT) tiger peng <tigerpeng2001 at yahoo.com> wrote: 

tp> There must be better way for removing the double quote in a CSV file optionally quoted by double quote.
tp> What I did as below is ugly and not reliable. Could anyone provide one beautify line?

tp>   $delimiter=chr(0227);
tp>   s/^"/$delimiter/g;
tp>   s/,"/,$delimiter/g;
tp>   s/"$/$delimiter/g;
tp>   s/",/$delimiter,/g;
tp>   s/"//g;
tp>   s/$delimiter/"/g;

Have you considered Text::CSV_XS or any other CSV parsing modules?

You could just say

$columns = $csv->getline($io); # you need an IO object

You can then use $columns, which is an array ref, any way you like.


More information about the Chicago-talk mailing list