Thread Anfänger-Problem (10 answers)
Opened by Gast at 2004-08-31 23:44

renee
 2004-09-01 00:07
#49728 #49728
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Du kannst Dir ja schnell ein Formular basteln, dass Du dann mit localhost/formular.html aufrufst
Code: (dl )
1
2
3
4
5
<html>
<body><form action="./cgi-bin/temperatur.pl" method="post">
<input type="text" name="fahrenheit"><br />
<input type="submit" value="Celsius berechnen">
</form></body></html>


und Dein temperatur.pl sieht dann so aus:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!C:/Perl/bin/perl -w
use strict; # variablen jetzt mit 'my' deklarieren
use warnings;
use CGI; # das CGI-Modul ist sehr praktisch
use CGI::Carp qw(fatalsToBrowser);

my $cgi = CGI->new();
print $cgi->header(-type => 'text/html'); # früheres print "Content-type:..."

my $fahr = 33;

my $temp = $cgi->param('fahrenheit'); # die Benutzereingabe bekommen
if(defined($temp)){
$fahr = $temp;
}

my $cel = 0;
$cel = ($fahr-32)*5/9;
print"$fahr Grad Fahrenheit entsprechen",sprintf("%3d Grad Celsius\n",$cel);
\n\n

<!--EDIT|renee|1093982889-->
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Anfänger-Problem