Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why I got duplicated records?

Status
Not open for further replies.

kate8

Programmer
Joined
Feb 14, 2001
Messages
184
Location
US
Hi, everyone, I need your help!
I encounter a problem.
My company has an online registration program. We are using Perl to handle the form submit. When user submits the application form, the Perl program will check the record (flat file database) the userID and memberID. If any of them is found in the database, the application won't be accepted; otherwise, the form information will be stored into the data file.
The program works fine until yesterday. Yesterday, the data management person found out that there are two identical records in the data files. The userID and memberID , also other information is exactly same. I checked my program, but couldn't find anything wrong. The code is:

$found = "0";
while ( ($line = <IN>) && ($found == 0) )
{
chomp($line);
@member = split(/\[\w*\]+/,$line);
if (($memID eq $record[1]) || ($userID eq $record[8])){
$found = &quot;1&quot;;
}
}
If $found is not zero, the program won't call the store record function. But this time it stored it.
How could this happen? What is the possibility for this case? Is there any one has any idea about it? Yesterday, our server experienced slowness on the firewall and took down the Internet access. If the user clicked the submit form, but didn't get the response, then back the form page and submit it again, could Perl store the second record when the first one is processing?

Thank you for any help!!
 
Have you tried to deliberately submit a duplicate to make sure that the code works? It may not be the cause of your problem, but you're mixing string and numeric usage of the $found variable. You set it to &quot;0&quot; or &quot;1&quot;, but you use the numeric compare $found == 0. That's just bad practice. Set $found to 0 or 1, not the string values.

Next, you are splitting the line into the array @member, but you are checking array elements $record[1] and $record[8]. That can't possibly be working! You should be checking $member[1] and $member[8].
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
I am sorry. I made a mistake and confused you. The original code is $member[1] and $member[8]. I made the change when I posted the question.
I have tried several ways to test the code. Even use that duplicated record to do the test, the application wasn't been accepted. The code is working. It has been working for more than one year. I didn't write all the original code. I wrote part of it and now maintain all the codes. You are right. The $found was set to string, and the code uses the numeric comparison. I will correct it and test the code again. Thank you!!
But I think that is not the problem for this case. Since I have tested the code many times, it won't accept the application if I use a memberID or userID which is same as a record in the data file. I have no idea what that problem could be.
Thank you for your response!!

 
The only other thing I can think of is if there is some embedded whitespace in one of the fields in the record is would throw off the split.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top