Thread file lesen und als html ausgeben (14 answers)
Opened by oerbb at 2004-04-16 20:46

x-man
 2004-04-17 17:52
#2126 #2126
User since
2003-09-11
67 Artikel
BenutzerIn
[default_avatar]
Benutze diesen:

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
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use strict;

my $file = "hosts.txt"; # Die zu lesende Datei
my (@ioc, @kb, @sdc); # 3 Arrays für 3 Datentypen
open(FH,"<$file") || die $!; # Datei $file öffnen
while(<FH>){ # Schleife
chomp;
push @ioc, $_ if($_ =~ /^psaf/); # Wenn Zeile mit psaf anfängt, rein ins @ioc. $_ ist eine vordefinierte Varialble
push @kb, $_ if($_ =~ /^psrs/); # Wie oben
push @sdc, $_ if($_ =~ /^pssd/); # Wie oben
}
close(FH);

print "Content-type: text/html\n\n";
print "<html>\n";
print "<body>\n";
print "<table width=100% cellpadding=5 cellspacing=1 bgcolor=black>\n";
foreach(sort @ioc){
print "<tr>\n";
print "<td bgcolor=white>$_</td>\n";
print "</tr>\n";
}
foreach(sort @kb){
print "<tr>\n";
print "<td bgcolor=white>$_</td>\n";
print "</tr>\n";
}
foreach(sort @sdc){
print "<tr>\n";
print "<td bgcolor=white>$_</td>\n";
print "</tr>\n";
}
print "</table>\n";
print "</body>\n";
print "</html>\n";


Hab getestet und es läuft. Im alten Code sind Tippfehler gefunden worden. Sorry!\n\n

<!--EDIT|x-man|1082210221-->

View full thread file lesen und als html ausgeben