Gossamer Forum
Home : General : Perl Programming :

find duplicate entries

Quote Reply
find duplicate entries
i want to search for duplicate content in multiple fields. for example, if a spammer enters the same text in firstname, lastname, address, etc., i want to display an invalid entry error or just delete it. i've been using the following code:
Code:
my ($i, $j, $howmany);

$i = 0;
$howmany = @db_compare_fields; # number of elements
while ($howmany > $i) {
$j = $i + 1;
while ($howmany > $j) {
if ($in{$db_compare_fields[$i]} && $in{$db_compare_fields[$j]}) { # don't compare blank fields
if ($in{$db_compare_fields[$i]} eq $in{$db_compare_fields[$j]}) {
push (@input_err, "Invalid $db_compare_fields[$j]"); # show second field in error
} #if match
} # if fields not blank
$j++;
}
$i++;
}

@db_compare_fields is a list of the fields i want to compare
there must be a simpler way to do this. in addition, the error message contains duplicates. that is, if the person enters the same text in firstname, lastname, and phone, the error says

Code:
Invalid lastname
invalid phone
invalid phone
i only want phone listed once. please help.

Subject Author Views Date
Thread find duplicate entries delicia 3396 Jan 22, 2021, 11:43 AM
Thread Re: [delicia] find duplicate entries
Andy 3367 Jan 23, 2021, 12:54 AM
Thread Re: [Andy] find duplicate entries
delicia 3358 Jan 23, 2021, 6:13 AM
Thread Re: [delicia] find duplicate entries
Andy 3358 Jan 23, 2021, 6:18 AM
Thread Re: [Andy] find duplicate entries
delicia 3352 Jan 23, 2021, 6:32 AM
Thread Re: [delicia] find duplicate entries
Andy 3348 Jan 23, 2021, 7:23 AM
Post Re: [Andy] find duplicate entries
delicia 3337 Jan 23, 2021, 8:24 AM