#!/usr/bin/perl -w

# Usage: unsub2sql.pl <txtlist> <sqlout> <startnum1> <startnum2>
#
# Example:  unsub2sql.pl txtlist.txt sqlout.txt 25861
#
# David Harris, Version of 3 Jan 2006 22:10 GMT

# ------------------------------------------------

# Check the number of arguments on the command line:
if ($#ARGV+1 != 3) {
  die "unsub2sql.pl needs <txtlist> <sqlout> <startnumber> as arguments";
};
# Check existence of the textfile and email listing file:
(open TXTLIST, "<$ARGV[0]") or die "unsub2sql.pl txtlist file $ARGV[0] not found.\n";
(open SQLOUT, ">$ARGV[1]") or die "unsub2sql.pl SQL file not made.\n";
$startnum = $ARGV[2];
chomp $startnum;
$i = 0;
#Read through TXTLIST file:
while ($lineread = <TXTLIST>) {
  #chomp $lineread;
  $personsernum = $startnum+$i;
  print SQLOUT "$personsernum\|isk12sci\|NULL\|NULL\n" ;
  $i++;
}

close SQLOUT;
close TXTLIST;
exit;