in reply to Some problem pattern matching
Possibly you have a logic error here - the "$sth3->execute()" call depends only on the outer two loops, but it is occurring in the innermost loop. Thus if more than one bacteria name matches for a given abstract/contaminant pair, you will end up trying to insert duplicate records into that "PM_cont" table. Possibly the "$sth3->execute()" call should be moved out one level.my $sth = $dbh->prepare( "SELECT pmid, abstract FROM PM_text " . "WHERE title LIKE '%E.coli%'" ); $sth->execute; my @text_refs = ($sth->fetchrow_hashref()); $sth->finish; ... for my $text_ref (@text_refs) { for my $cont_name (@cont_names) { if ($text_ref->{abstract} =~ m/$cont_name/im) { for my $bact_name (@bact_names) { if ($text_ref->{abstract} =~ m/$bact_name/im) { print "matched at text $text_ref->{pmid}, " . "for $cont_name and $bact_name\n"; $sth2->execute( $bact_name, $cont_name, $text_ref->{pmid} ); $sth3->execute( $cont_name, $text_ref->{pmid} ); } } } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Some problem pattern matching
by eMBR_chi (Acolyte) on Apr 07, 2010 at 15:26 UTC |