[quote=Strat,26.08.2003, 16:32]1. Kennst Du das Modul
CGI?
...
durch den folgenden:
use CGI;
my $cgi = CGI->new();
my %Formular = $cgi->Vars();
Dann hast du schon mal viel schwierigen Code, der zudem noch fehleranfaellig ist, vermieden.
2.
open HTML,'<html.html';
print <HTML>;
close HTML;
Kann da irgenwie das Oeffnen der Datei html.html fehlschlagen?
my $file = "html.html";
unless (open (HTML, $file)) {
print "Fehler: konnte die Datei '$file' nicht oeffnen: $!
";
}
else {
print <HTML>;
close HTML;
}
[/quote]
Bin gerade dabei mich in Perl einzuarbeiten. Das mit dem CGI-Modul hab ich prinzipiell schon verstanden, aber zum selbst ausprobieren fehlen mir noch etwas die Grundkenntnisse.
Ich habe es trotzdem mal ausprobiert:
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
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI;
my $cgi = CGI->new();
my %Formular = $cgi->Vars();
my $test = 1;
if( $test != 0) {
print "Content-type: text/html\n\n";
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">', "\n";
print "<html><head><title>CGI-Feedback</title></head>\n";
print "<body><h1>Resultate von <i>Formular.pl</i></h1>\n";
print "<b>Übertragene Daten:</b><br>";
while (($Name, $Wert) = each(%Formular)) {
print "Das Formularfeld $Name besitzt den Wert $Wert.<br>\n";
}
print "</body></html>\n";
}
Das Ergebnis ist folgendes:
Software error:
Global symbol "$Name" requires explicit package name at c:\inetpub\scripts\formular.pl line 25.
Global symbol "$Wert" requires explicit package name at c:\inetpub\scripts\formular.pl line 25.
Global symbol "$Name" requires explicit package name at c:\inetpub\scripts\formular.pl line 26.
Global symbol "$Wert" requires explicit package name at c:\inetpub\scripts\formular.pl line 26.
Global symbol "$Name" requires explicit package name at c:\inetpub\scripts\formular.pl line 93.
Global symbol "$Wert" requires explicit package name at c:\inetpub\scripts\formular.pl line 93.
Global symbol "$Wert" requires explicit package name at c:\inetpub\scripts\formular.pl line 94.
Global symbol "$Name" requires explicit package name at c:\inetpub\scripts\formular.pl line 94.
Execution of c:\inetpub\scripts\formular.pl aborted due to compilation errors.
For help, please send mail to this site's webmaster, giving this error message and the time and date of the error.
Zu Punkt 2)
War ein Vorschlag von Ishka zum Laden einer Folgeseite (nach Formularabsenden). Leider klappt das momentan weder so, noch mit redirect.
@renee
Quotemy $test = 0; # ich versteh nicht so ganz was das soll, übernehme es aber von dir...
if($test != 0){ # kann bei deinem Skript allerdings nie passieren
Ist nur für mich zum Testen gedacht, damit ich mal schnell zwischen den beiden Varianten switchen kann.