in reply to csv output

There are several possibilities to do so:
You could do it with the Modules DBI and DBD::Csv, (treated as database), or Text::Csv, or do it by yourself.

The rules are about: The columns are separated with a special char; if this char is inside a column, then the column is embraced by "" (or sometimes '').

my $csvSep = ','; # comma as csv-separator foreach my $line (@rows){ # e.g. 2-dim array my @columns = @$line; print join($csvSep, # join by $csvSep map { /\Q$csvSep/ ? "\"$_\"" : $_ # if $csvSep found in Value: "val" } @columns; # take columns ), "\n"; # and a newline... } # foreach

Best regards,
perl -le "s==*F=e=>y~\*martinF~stronat~=>s~[^\w]~~g=>chop,print"

Replies are listed 'Best First'.
Re (tilly) 2: csv output
by tilly (Archbishop) on Mar 14, 2002 at 19:10 UTC
    You at least put some effort into this answer, but your code is not sufficient to produce valid output if, for instance, the contents of a field was just a double-quotation mark.