Hi,
I'm a newbie struggling to total up a web users survey for work. The HTML form is a
separte document, which calls up the cgi script. I've been reading the CGI module
and
figured out how to get the key/value paris. Now, I want to tally the answers,
i.e. 10 users choose question 2 (Q2), I want it to show:
Question2: 10
...here's what I've come up with help from the CGI module documenation.
any clues in what I'm doing wrong with the sub get_total() ?
thanks for any help, Pam
----------------------------------
#!/usr/local/bin/perl
use lib '/usr/local/lib';
use CGI;
$cgi = new CGI;
print $cgi->header;
get_answers();
get_total();
sub get_answers {
my($query) = @_;
my(@values,$key);
print "<H2>Here are the current settings in this form</H2>";
foreach $key ($cgi->param) {
print "<STRONG>$key: </STRONG> ";
@values = $cgi->param($key);
print join(", ",@values),"<BR>\n";
}
}#end subroutine get_answers
sub get_total{
my $query = @_;
my(@values, $key);
print "<H2>Here are the totals: </H2>";
if ($value ($cgi->param('Q2') ne ' ')){
$count2++;
print ("Question2: $count\n");
}
}#end subroutine get_total
print $cgi->end_html;