Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

kcott's scratchpad

by kcott (Archbishop)
on Sep 22, 2010 at 21:42 UTC ( [id://861372] : scratchpad . print w/replies, xml ) Need Help??

For Tux:

#!/usr/bin/env perl -l use strict; use warnings; use Text::CSV; my $csv = Text::CSV::->new(); my $cols = @{ $csv->getline(\*DATA) }; my $query = 'INSERT INTO table (' . join(',' => map { "col$_" } 1 .. $ +cols) . ') VALUES (' . join(',' => ('?') x $cols) . ')'; print $query; __DATA__ a,b,c,d

Output:

INSERT INTO table (col1,col2,col3,col4) VALUES (?,?,?,?)