#!usr/local/bin/perl-w
#sub.pl
#Author: Vincent Wang
#Time  :January 13, 2000

$Studentfile="class.txt";
$Statusfile="status.txt";

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

@pairs = split(/&/,$buffer);
foreach $pair(@pair){
($name,$value) = split(/=/,$pair);
$value=~ tr/+/ /;
$value = ~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}

open (STUDENT,"$Studentfile");

@class = split (/ /,<STUDENT>);
$count=@class;

$userid= $FORM{'userid'};
$password=$FORM{'password'};

$pos=0;
while ($pos<$count){
   $pword=$pos+1;
   $idmatch = $class[$pos] cmp $userid;
   $pwdmatch= $class[$pword] cmp $password;
   if (($idmatch == 0) && (pwmatch ==0)){
         print "Content-type:text/html\n\n";
	 print "<HTML><HEAD><TITLE>test</TITLE></HEAD><BODY>\n";
         print "match!!</BODY></HTML>\n";
    }
   else{
         print "Content-type:text/html\n\n";
         print "<HTML><HEAD><TITLE>test</TITLE></HEAD><BODY>\n";
         print "match!!</BODY></HTML>\n";
}
}