@headers = qw(one two three); @rows = ( ['yes', 'no', 'maybe'], ['17" monitor', 'a;b', "foo\nbar"], ); { local($\, $,) = ("\n", ";"); print map { my $s = $_; $s =~ s/([\n;])|"/ $1 || '""' /ge and $s = qq["$s"]; $s } @$_ foreach \@headers, @rows; }