> Hello, > > I am trying to do an import of a Tab De-limited file and then > extract certain fields. >
This has what to do with CGI? Your question is better asked to [EMAIL PROTECTED] > I am looking to general comments and or a better more concise way of doing this, > Thanks in advance... > > Dave Gilden -- Ft. Worth-less Texass > > Here is what I have so far (and it is not tested and my be incorrect!) > > > ###Perl Code### > use strict; use warnings; > open (FH, $fileIn) || "die Problem reading $fileIn $!\n"; > I suspect the above ought to have C<die> either outside the string, or in addition to the string. Have you tested this code? > while(<FH>){ > push(@musicians, $_); > } > close FH; > > > foreach (@musicians){ > chomp; > > @tmpArray = split(/\t/,$_); > > $ssNum = $tmpArray[0]; > $fName = $tmpArray[3]; > $lName = $tmpArray[4]; > $zip = $tmpArray[8]; > $city = $tmpArray[9]; > $state = $tmpArray[10]; > $memberStatus = $tmpArray[12]; > $phone = $tmpArray[19]; > $instrument = $tmpArray[21]; > $email = $tmpArray[33]; > Why bother transferring the individual array values into named variables if you don't intend on using the names anywhere. What happens when the columns are in a different order? > > #### INSERT Into Data in to mySql Database ################### > > # using place holders > $sql = "insert into $table_name values (null, ?, ?, ?, ?,?,?,?, ?, ?, ?);"; > $sth = $dbh->prepare($sql); > $sth->execute($ssNum,$fName,$lName,$zip,$city,$state,$memberStatus,$phone,$instrument,$email); > > ## more code..... > } > MySQL comes with an import utility that I believe will take CSV/TSV files. Alternatively you may want to check out the Text::CSV module, or one of the other offshoots. WHat happens when one of the fields contains a tab, aka it is quoted? http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>