INSERT INTO Books Title,FileID,author,authInv) VALUES ('Literature','30001f3d','John M. Doe','Doe, John M.'); #### print "What is the directory where we'll be working: "; $directory = ; chomp ($directory); print "What is the file name, with a file extension: "; $file = ; chomp ($file); $originalfile = "$directory/$file"; open(FIRST, "<$originalfile" ) || die "I cannot open $originalfile. $!"; @contents = ; close(FIRST); $new = "$directory/SQL-Insert-Titles.sql"; unlink($new); open(SECOND, ">$new") || die "I cannot open $new. $!"; foreach $line (@contents) { @splitline = split /\|/, $line; $title = $splitline[0]; $file = $splitline[1]; $author = $splitline[2]; $authinv = $splitline[3]; chomp($title); chomp($file); print SECOND "INSERT INTO Books Title,FileID,author,authInv) VALUES ('$title','$file','$author','$authinv')\;\n"; } close(SECOND); print "\n\tDone."; |