Below the code is a rough breakdown of the TXT file I am pulling in from.
I ran a basic perl -c on this to see any syntax errors, and I got back a
"Global symbol "@semm_count" requires explicit package name at Line 24.
So I apparently have that variable set wrong, but I am not sure how. I am missing some larger piece and not sure what it is or how to get it to click in my head, I am thinking about this way to much. SQL wasn't this hard to pick up and neither was Flash or Javascript
All I need to get this to do is display:
Seminar Name: Number registered:
1 2
2 3
3 1
4 2
total Students registered: 8
#!c:/perl/bin/perl.exe
#super.cgi - saves form data to a file, and creates a dynamic
#Web page that displays a message and survey statistics
print "Content-type: text/html\n\n";
use CGI qw(:standard);
use strict;
#declare variables
my ($name, $semm, @records);
#my @semm_count = (0, 0, 0, 0);
my %semm_count = ("1", 0,
"2", 0,
"3", 0,
"4", 0);
#calculate survey statistics
open(INFILE, ">>", "c05ex5.txt")
or die "Error opening c05ex5.txt. $!, stopped";
@records = <INFILE>;
close(INFILE);
foreach my $rec (@records) {
chomp($rec);
($name, $semm) = split(/,/, $rec);
$semm_count[$semm] = $semm_count[$semm] + 1;
}
#generate HTML acknowledgment
print "<HTML><HEAD><TITLE>WKRK-TV</TITLE></HEAD>\n";
print "<BODY>\n";
print "<H2>Seminar Total</H2>\n";
print "<TABLE>\n";
print "<TR><TD>Seminar</TD> <TD>Total</TD></TR>\n";
foreach my $key ("Computer Maintenance", "Microsoft Office", "Unix Essentials", "CGI/PErl") {
print "<TR><TD>$key</TD> <TD>$semm_count{$key}</TD></TR>\n";
}
print "</TABLE>\n";
print "</BODY></HTML>\n";
Text file:
StudentA,1
StudentB,2
StudentC,3
StudentD,4
StudentE,1
StudentF,2
StudentG,2
StudentH,4