Could you suggest how to prevent the following script from reloading when 'Submit' is pressed ?



use strict;
use warnings;
use CGI qw(:standard :html3);

our @results;

#require ("");

print header;
start_html(' questions shuffle'),
print h2 ("\t questions shuffle");

my @questionsets = ("dt_questions.txt", "questions2.txt", "dt_questions.txt");

foreach my $setfile (@questionsets){
	&choose ($setfile);


sub choose {

my $set = shift;

open (FILE, $set ) || die "Error opening file : $!\n";
my @questions =<FILE>;
my @numbers = (1..40);#number of questions to choose from
my $limit = 25; #number of questions to be selected
my %list = ();

print h4 ("\t $set");

#populate the hash with random numbers
while (keys %list < $limit) {
   $list{$numbers[rand @numbers]}=1;
# print the selected questions in a table
	print "<TABLE BORDER=2 bgcolor='lightgrey' WIDTH=90%>";
   	print (td "<pre>\ @questions[ keys %list]</pre>");
    	print "</TABLE>";
foreach my $values(keys (%list)){

#print "@questions[ $values]";

push  (@results, @questions[ $values]);



###### Answer Sheet
print h3 ("Answer Sheet");

print p;
print start_form;

my $count;
for (0..$#results ){

$count = "answer"."$_";
print popup_menu(-name=>"$count",
                                    -values=>['0','1','2','3','4','5', '6','7','8','9','10']);
print "\n@results[$_]\n";

print p;
print submit(-name=>'preview', -value=>'Submit');;

print end_form,

if (!param ('preview')){exit;}

## print scores
my $score;
for (0..$#results ){
my $answer = "answer"."$_";
#print param ("$answer");

$score = $score + param ("$answer");}
my $max = ($#results +1)*10;
print "The total score is : $score";
print p;
print "Maximum possible score is $max ";

you can use session cookies, or you can log there ip. I would just use session cookies, and if the person doesnt accept cookies then dont allow them to view page, or something like that.