a one-liner that returns a quote-comma scalar, from an array of values.
my $quoted = join ',', map{qq{"$_"}} qw(foo bar bas); $quoted is now "foo","bar","bas"

Replies are listed 'Best First'.
Re (tilly) 1: quick quote comma
by tilly (Archbishop) on Dec 02, 2000 at 03:04 UTC
    And what happens if your data has quotes in it? Here is a version that handles that with the quoting rules used by the CSV format:
    sub list2csv { my $line = join ",", map { my $t = $_; $t =~ s/"/""/g; $t =~ /\W/ ? qq("$t") : $t; } @_; $line .= "\n"; return $line; }
    Going in reverse is left as an exercise for the reader. Note for the unwary, what about trailing commas, embedded commas, and embedded returns? :-)