Thread Taschenrechner einbindung in Skript (4 answers)
Opened by Justin at 2013-12-20 10:21

GwenDragon
 2013-12-20 10:40
#172674 #172674
User since
2005-01-17
14548 Artikel
Admin1
[Homepage]
user image
Eben kurz zusammengemixt:

Code (html): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
<title>Taschenrechner</title>
<style type="text/css"></style>
</head>
<body>
<form action="/cgi-bin/testFORMULAR.pl" method="post">
<fieldset>
<legend>Addieren</legend>
<input name="wert1" type="text" value="" />
<input name="wert2" type="text" value="" />
<input type="submit" name="go" value="Rechnen"/>
</fieldset>
<form>
</body>
</html>


Code (perl): (dl )
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
use strict;
use warnings;
use CGI;
#use CGI::Carp qw(fatalsToBrowser);

my $cgi       = CGI->new;
my @Feldnamen = $cgi->param();

my $ergebnis;

my $wert1 = $cgi->param('wert1') // '';
$wert1 = '?' if not length $wert1;

my $wert2 = $cgi->param('wert2') // '';
$wert2 = '?' if not length $wert2;

if ( $wert1 ne '?' and $wert2 ne '?' ) {
    $ergebnis = $wert1 + $wert2;
}
else {
    $ergebnis = 'ERROR: Werte fehlen';
}

print $cgi->header(),
  $cgi->start_html('CGI-Feedback'),
  $cgi->h1('Taschenrechner '),
  $cgi->i('Dein Ergebnis:');
foreach my $Feld (@Feldnamen) {
    print $cgi->param($Feld), $cgi->br;
}
print $cgi->strong($ergebnis), $cgi->br;

print $cgi->end_html();
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

View full thread Taschenrechner einbindung in Skript