|< 1 2 3 4 ... 6 >| | 55 Einträge, 6 Seiten |
$data('total')++;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/C:/Perl/bin/perl.exe
#use strict;
use CGI qw(:standard);
my $results = 'umfrage_ergebnisse.txt';
my %data = ();
my $thing = '';
my $val = 0;
print print "Content-type: text/html\n\n";
print "Hallo";
open(RESULTS, $results) or die "Ergebnisdatei konnte nicht geöffnet werden: $!";
while (<RESULTS>){
($thing, $val) = split(' ');
$data('$thing') = $val;
}
close(RESULTS);
#Gesamtsumme
$data('total')++;
#Alter
if (!param('age')){
$data('age_na')++
} else {
if (param('age') eq 'under18') {
$data('age_under18')++;
}
elsif (param('age') eq '18to34') {
$data('age_18to34')++;
}
elsif (param('age') eq '35to50') {
$data('age_35to50')++;
}
elsif (param('age') eq '50plus') {
$data('age_50plus')++;
}
}
#Geschlecht
if (!param('sex')) {
$data('sex_na')
} else {
if (param('sex') eq 'male') {
$data('sex_m')++;
}
elsif (param('sex') eq 'female') {
$data('sex_f')++;
}
}
#Perl
if (!param('perl')) {
$data('perl_na')++;
} else {
if (param('perl') eq 'yes') {
$data('perl_y')++;
}
elsif (param('perl') eq 'no') {
$data('perl_n')++;
}
}
open(RESULTS, ">$results") or die "In die Ergebnisdatei kann nicht geschrieben werden: $!";
foreach $thing (keys %data) {
print RESULTS "$thing $data{$thing}\n";
}
close(RESULTS);
print header;
print start_html('Danke');
print <<HTM;
<h1>Danke, dass Sie das Umfrageformular ausgefüllt haben!</h1>
<p>Die bisherigen Ergebnisse:</p>
<p>Geschlecht:</p>
<table border="0">
<tr>
<th>Männlich</th>
<td>
HTM
print &prozent('sex_m'), "\n</td>\n</tr>\n";
print "<tr>\n<th>Weiblich</th>\n<td>\n";
print &prozent('sex_f'), "\n</td>\n</tr>\n";
print "<tr>\n<th>Keine Antwort</th>\n<td>\n";
print &prozent('sex_na'), "\n</td>\n</tr>\n";
print "</table>\n";
print "<p>Alter:</p>\n"
print '<table border="0">\n<tr>\n<th>Unter 18</th>\n<td>\n';
print &prozent('age_under18'), "\n</td>\n</tr>\n";
print '<tr>\n<th>18 bis 34</th>\n<td>\n';
print &prozent('age_18to34'), "\n</td>\n</tr>\n";
print '<tr>\n<th>35 bis 50</th>\n<td>\n';
print &prozent('age_35to50'), "\n</td>\n</tr>\n";
print '<tr>\n<th>Über 50</th>\n<td>\n';
print &prozent('age_50plus'), "\n</td>\n</tr>\n";
print '<tr>\n<th>Keine Antwort</th>\n<td>\n';
print &prozent('age_na'), "\n</td>\n</tr>\n";
print "</table>\n";
print "<p>Perl-Programmierer?\n</p>";
print '<table border="0">\n<tr>\n<th>Ja</th>\n<td>\n';
print &prozent('perl_y'), "\n</td>\n</tr>\n";
print '<tr>\n<th>Nein</th>\n<td>\n';
print &prozent('perl_n'), "\n</td>\n</tr>\n";
print '<tr>\n<th>Keine Antwort</th>\n<td>\n';
print &prozent('perl_na'), "\n</td>\n</tr>\n";
print "</table>\n";
print end_html;
sub prozent {
if (defined $data{$_[0]}) {
return sprintf("%.1f%%", $data{'_[0]} / $data{'total'} * 100);
} else {
return '0%';
}
}
print "<table border='0'>\n<tr>\n<th>Unter 18</th>\n<td>\n";
|< 1 2 3 4 ... 6 >| | 55 Einträge, 6 Seiten |