#!/usr/bin/perl
use CGI ':standard';
print header;
$prez=param('prez');
$vice=param('vice');
$secretary=param('secretary');
$count = 1;
print "PREZ " . $prez ."
";
print "vice " . $vice . "
";
print "secretary " . $secretary . "
";
#this opens the voting text file and extracts the information
open (VOTE, "){
($user[$count],$vote[$count])=split (/\|/);
$count++
}
close VOTE;
#the variables for prez,vice and secretary are compared to these names and increment there count by one for each vote they recieve
if ($prez eq 'sam'){
$vote[1]++;
}
if ($prez eq 'hosea'){
$vote[8]++;
}
if ($prez eq 'howard'){
$vote[6]++;
}
if($vice eq 'wendy'){
$vote[7]++;
}
if($vice eq 'ann'){
$vote[3]++;
}
if($vice eq 'george'){
$vote[2]++;
}
if($secretary eq 'martha'){
$vote[5]++;
}
if($secretary eq 'tom'){
$vote[4]++;
}
if($secretary eq 'david'){
$vote[9]++;
}
$count = 1;
#this is suppose to be the while loop which runs $vote[1] to #vote[9], but it only saves the data for sam because he is $vote[1] all others will show as a count of one if voted for, but will not increment if voted for again
open VOTE, ">vote.txt";
while (10 > $count){
print VOTE $user[$count]."|".$vote[$count];
$count++;
}
close VOTE;
#this displays the vote tally for each candidate
print "sam has $vote[1] votes
";
print "hosea has $vote[8] votes
";
print "howard has $vote[6] votes
";
print "wendy has $vote[7] votes
";
print "ann has $vote[3] votes
";
print "george has $vote[2] votes
";
print "martha has $vote[5] votes
";
print "tom has $vote[4] votes
";
print "david has $vote[9] votes
";
print " @vote";
print "main page";