in reply to inserting in a database

my @identifier = ("A1","B1","C1","D1"); my @idfeat = ("A1","B1"); my $pattern = join ( "|", @idfeat ); for my $eu ( 0 .. $#identifier ) { if ($identifier[$eu] =~ /$pattern/ ){ print "$identifier[$eu], Feature\n"; #my $sth=$dbh->prepare("INSERT INTO dd VALUES('$identifier[$eu +]','Feature')"); #$sth->execute(); #$sth->finish; } else { print "$identifier[$eu], Bug\n"; #my $sth=$dbh->prepare("INSERT INTO dd VALUES('$identifier[$eu +]','Bug')"); #$sth->execute(); #$sth->finish; } }

Replies are listed 'Best First'.
Re: Re: inserting in a database
by Anonymous Monk on Nov 24, 2003 at 14:19 UTC
    Just be sure to do a $identifier[$eu] = $dbh->quote( $identifier[$eu] ); before you prepare ;)
      ... or use place holders instead:
      my $sth = $dbh->prepare(" INSERT INTO dd VALUES(?,?) "); $sth->execute($identifier[$eu],'Feature');
      and let the module do intelligent quoting and provide statement caching for you (like hmerrill provided). Kudos to Taulmarill, however, for using
      for my $eu (0..$#identifier) {
      instead of
      for (my $eu = 0; $eu <= (scalar(@identifier)); $eu++) {

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)