#!/usr/bin/perl

# This program takes the roll number of the student. Then  it searches
# a file called "datafile" if the roll number exists. If it does, it prints
# the marks for "quiz1" and "quiz2" 

&ReadGetData(*datain);		# This line gets the input string

    print &PrintHeader;
    print("<body>");
    @input=split(/=/,$datain);

    $rollno=$input[1];		# The roll number is now in $rollno
    
    open(fp,"datafile");	# Open the file which contains the marks
    $line=<fp>;

    while($line ne ""){		# Search the roll no in the file by scanning each line
    	@parts=split(/\s+/,$line);

	if($rollno eq $parts[0]){	# If roll nos. match, print the marks

		print("<center> The marks in quiz 1 = ",$parts[1],"<br><br>");
		print("<center> The marks in quiz 2 = ",$parts[2],"<br>");
	}
	$line=<fp>;
    }	

    print("</body>");

    close(fp);
	

sub PrintHeader
{
	print "Content-type: text/html\n\n";		# The header which indicates that 
							# incoming data is html
}


sub ReadGetData
{
	local(*query_string)=@_;

	$query_string=$ENV{"QUERY_STRING"};

	return 1;
}	


