ok so i've been working on this script for like 3 hours total now and its a simple script, and i think i made a dumb mistake a can't find. so here is it take a look.
#!/usr/bin/perl
#super.cgi - saves form data to a file, and creates a dynamic web page
print "Content-type: text/html\n\n";
use CGI qwstandard);
use strict;
#declare variables
my ($game, $commercial @records);
my @game_count = (0,0,0);
my %comm_count = ("Budweiser", 0,
"FedEx", 0,
"MasterCard", 0,
"Pepsi", 0);
#assign input items to variables
$game = param( 'game' );
$commercial = param( 'commercial' );
#save form data to a file
open(OUTFILE, ">>", "survey.txt"
or die "Error opening survey.txt. $!, stopped";
print OUTFILE "$game,$commercial\n";
close(OUTFILE);
#calculate survey statistics
open(INFILE, "<", "survey.txt"
or die "Error opening survey.txt. $! stoppped";
@records = <INFILE>;
close(INFILE);
foreach my $rec (@records) {
chomp($rec);
($game, $commercial) = split(/,/, $rec);
$game_count[$game] = $game_count[$game] + 1;
$comm_count{$commercial} = $comm_count{$commercial} + 1;
}
#generate HTML acknowledgement
print "<html><head><title>WKRK-TV</title></head>\n";
print "<body>\n";
print "<h2>Thank you for participating in our survey.</h2>\n";
print "<em><b>What did you think of the Super Bowl game?</em></b>\n";
print "<table> \n";
print "<tr><td>It was a great game.</td> <td>$game_count[0]</td></tr>\n";
print "<tr><td>It was a boring game.</td> <td>$game_count[1]</td></tr>\n";
print "<tr><td>I didn't watch the game.</td> <td>$game_count[2]</td></tr>\n";
print "</table><br>\n";
print "<em><b>Vote for your favorite Super Bowl Commerical:</em></b>\n";
print "<table>\n";
foreach my$key ("Budweiser", "FedEx", "MasterCard", "Pepsi" {
print "<tr><td>$key</td> <td>$comm_count{$key}</td></tr>\n";
}
print "</table>\n";
print "</body></html>\n";
the website its on it "
#!/usr/bin/perl
#super.cgi - saves form data to a file, and creates a dynamic web page
print "Content-type: text/html\n\n";
use CGI qwstandard);
use strict;
#declare variables
my ($game, $commercial @records);
my @game_count = (0,0,0);
my %comm_count = ("Budweiser", 0,
"FedEx", 0,
"MasterCard", 0,
"Pepsi", 0);
#assign input items to variables
$game = param( 'game' );
$commercial = param( 'commercial' );
#save form data to a file
open(OUTFILE, ">>", "survey.txt"
or die "Error opening survey.txt. $!, stopped";
print OUTFILE "$game,$commercial\n";
close(OUTFILE);
#calculate survey statistics
open(INFILE, "<", "survey.txt"
or die "Error opening survey.txt. $! stoppped";
@records = <INFILE>;
close(INFILE);
foreach my $rec (@records) {
chomp($rec);
($game, $commercial) = split(/,/, $rec);
$game_count[$game] = $game_count[$game] + 1;
$comm_count{$commercial} = $comm_count{$commercial} + 1;
}
#generate HTML acknowledgement
print "<html><head><title>WKRK-TV</title></head>\n";
print "<body>\n";
print "<h2>Thank you for participating in our survey.</h2>\n";
print "<em><b>What did you think of the Super Bowl game?</em></b>\n";
print "<table> \n";
print "<tr><td>It was a great game.</td> <td>$game_count[0]</td></tr>\n";
print "<tr><td>It was a boring game.</td> <td>$game_count[1]</td></tr>\n";
print "<tr><td>I didn't watch the game.</td> <td>$game_count[2]</td></tr>\n";
print "</table><br>\n";
print "<em><b>Vote for your favorite Super Bowl Commerical:</em></b>\n";
print "<table>\n";
foreach my$key ("Budweiser", "FedEx", "MasterCard", "Pepsi" {
print "<tr><td>$key</td> <td>$comm_count{$key}</td></tr>\n";
}
print "</table>\n";
print "</body></html>\n";
the website its on it "