Thread ein paar fragen - hilfe :/: njaa perl halt ^^ (46 answers)
Opened by Gast at 2005-07-05 21:49

renee
 2005-07-13 22:12
#5199 #5199
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Code: (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
34
35
36
37
38
39
40
41
#!/usr/bin/perl -w
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);


my $cgi = CGI->new();
print $cgi->header();

unless($cgi->param('id')){
print "<html><head><title>Logfile </title></head><body>\n";
print "<form action =\"/cgi-bin/comments.pl\" method=\"post\">\n";
print "<p><b> Logfilename eingeben </b> <br> \n";
print " <p> <input name =\"Logfilename\" size = \"40\" > </p> \n",
"<p> <input type='hidden' name =\"id\" value='1' > </p> \n";
print "<p> <input type = \"submit\" value = \"Ok\" > </p> \n";
print "</form>\n";
print "</body></html>\n";
exit(0);
}

my $a = "logfile-accesspoint-1.txt";
my $b = "logfile-accesspoint-2.txt";

my $file= $cgi->param("Logfilename");

if($file eq $a) {
logfile($a);
}
elsif($file eq $b) {
logfile($b);
}

sub logfile {
my ($file) = @_;
open(LOGFILE1, "<$file") or die "kann $f nicht oeffnen: $!\n";
while(<LOGFILE1>) {
print;
}
close LOGFILE1;
}


*) Der Vergleichsoperator bei Strings ist eq
*) Man sollte immer versuchen, Dinge zusammenzufassen (wie hier die Subroutine)
*) Du musst ne Fallunterscheidung machen, ob das Formular abgesendet wurde oder ob das Formular angezeigt werden soll
*) Du solltest Dir im Wiki nochmal den Artikel zum Thema "use strict" durchlesen...
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 ein paar fragen - hilfe :/: njaa perl halt ^^