Wenn das einfacher Text ist und Du das in HTML ausgibst, dann werden die Leerzeilen nicht angezeigt...
Skript:
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
42
43
#!/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 qq~<html><head><title>Logfile </title></head><body>
<form action ="/cgi-bin/comments.pl" method="post">
<p><b> Logfilename eingeben </b> <br>
<p><select name="Logfilename"><option>logfile-accesspoint-1.txt</option>
<option>logfile-accesspoint-2.txt</option></select> <br>
<p> <input type='hidden' name ="id" value='1' > </p>
<p> <input type="submit" value="Ok" > </p>
</form>
</body></html>~;
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>) {
next if(/^\s*?$/); # überspringe Leerzeilen... (für Reguläre Ausdrücke siehe perldoc perlre)
print;
}
close LOGFILE1;
}