I'm a bit confused on why this is happening and I'm hoping someone can shed some light on things for me. I read in information from a file which is comma delimted and I use the parsing routine I found in the Perl Cookbook. When it hits a name with " marks around it, it shifts everything over when doing the insert. I have put escape characters in the data before insertion for both quotes and apostrophes and when I run it with w single entry, it inserts correctly. When run on a longer list, the line that has the name in quotes shifts everything over by one during the insertion. I'm using MySQL as the database. Thanks in advance!
open(TEMP,"/usr/temp.txt"); while (defined($hline = <TEMP>)) { chomp( $hline ); $hline =~s/@/\@/g; my @CSV_Columns = Parse_CSV( $hline ); # Give the columns a title my $xtemp = $CSV_Columns[0]; $xtemp =~ s/\'/\\'/g; $xtemp =~ s/\"/\\"/g; # Load into database $query1 = "insert into tempdata values(NULL,'$xtemp', 'jparker\@presslaff.com', 'Jessee', 'jparker\@presslaff.com', '12345678','Test','1','T')"; $sth1 = $dbh->prepare($query1); $rc1 = $sth1->execute(); push (@tempArray, $xtemp); print "$xtemp\n"; } sub Parse_CSV { my $text = shift; my @new = (); push( @new, $+ ) while $text =~ m{ "([^\"\\]*(?:\\.[^\"\\]*)*)",?|([^,]+),?|,|}gx; push( @new, undef ) if substr( $text, -1, 1 ) eq ','; return @new; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]