Skip to content

Instantly share code, notes, and snippets.

@lysu
Created December 8, 2012 10:16
Show Gist options
  • Save lysu/4239693 to your computer and use it in GitHub Desktop.
Save lysu/4239693 to your computer and use it in GitHub Desktop.
Generate sql from file
my @ctypes=qw/0 1 0 1 1/;
while(<>) {
chop;
@F=split('\|', $_);
print "insert into table values(";
foreach my $col (@F) {
my $type=shift(@ctypes);
print ($type == 1 ? '"'.$col.'"' : $col);
print ",";
}
print "0);\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment