#!/usr/bin/perl
$inputfile = "reg.t";
$backup = "reg.bac";

$inputfile = "reg_client.db";

$command = "cp $inputfile $backup";
$system($command);
$command = "mv $inputfile client.tmp";
system($command);
##open(F,$inputfile);
open(F,"client.tmp");
@temp = localtime(time);
print $t = (@temp[5]*10000)+(@temp[4]*100)+@temp[3];
while(<F>){
	@data = split(/:/,$_);
	if(@data[0] =~ /not/){
		if(($t-@data[4]) >= 100){
			open(Fout,">>trash");
			print Fout $_;
			close(Fout);
			#&emailto;
		}else{
			open(Fout,">>remain.db");
			print Fout $_;
			close(Fout);
		}
	}
}
close(F);
$command = "cat remain.db >> $inputfile";
system($command);
system('rm remain.db');
exit;
sub emailto{
	print "sendmail to @data[2] @data[4]";
	open(MAIL,"| /usr/bin/mail @data[2]");
	print MAIL "Reply-to: clinton\@tlcplus.com\n";
	print MAIL "Subject: TLCPLUS\n\n";
	print MAIL "Remember the expired day for the registration\n";
	close(MAIL);
	
}
