#!/usr/bin/perl -w

# Usage: dups.ender.pl <INFIL> <OUTFIL> <starting-serial-number>
#
# Example:  dups.ender.pl dups.ender.txt dups.ender.sql 
#
# David Harris, Version of 12 Jan 2006 16:06 PST

# ------------------------------------------------

# Check the number of arguments on the command line:
if ($#ARGV+1 != 2) {
  die "dups.ender.pl needs <INFIL> <OUTFIL>  as arguments";
};
# Check existence of the textfile and email listing file:
(open INFIL, "<$ARGV[0]") or die "dups.ender.pl INFIL file $ARGV[0] not found.\n";
(open OUTFIL, ">$ARGV[1]") or die "dups.ender.pl OUTFIL file not made.\n";
#chomp $startsernums;

#Read through INFIL file:
while ($lineread = <INFIL>) {
  chomp $lineread;
  ($n1, $n2) = split(/\|/, $lineread);

    print OUTFIL "DELETE FROM `$person` 
            WHERE `personsernum` = \'$n1\';\n" ;
    print OUTFIL "UPDATE `$personfacts`
            SET `personsernum` = '$n2'
            WHERE personsernum = '$n1';\n" ;
}
close OUTFIL;
close INFIL;
exit;