<img src="http://www.perlmonksflair.com/kcott.jpg" alt="PerlMonks Badge: kcott"
title="PerlMonks Badge: kcott. See http://www.perlmonksflair.com/." />
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 (?,?,?,?)
|