my $insert_sql = qq{ INSERT INTO dd VALUES(?, ?) }; my $sth_insert=$dbh->prepare($insert_sql); for (my $eu=0;$eu<=(scalar(@identifier));$eu++){ my $match_found = 0; foreach my $id(@idfeat) { if ($id eq $identifier[$eu]){ $match_found = 1; # found a match last; # break out of the foreach } } if ($match_found) { $sth_insert->execute($identifier[$eu], 'Feature'); } else { $sth_insert->execute($identifier[$eu], 'Bug'); } } $sth_insert->finish;