Ausgabe wird plötzlich falsch dargestellt ?
xNeTworKx
- perl
Hallo,
Ich habe eine dynamische News Seite auf meiner hp, die alle Einträge ausgibt, die ich per Eingabemaske eintragen kann.
Auf meiner neuen Seite habe ich erst 2 Einträge gemacht. Beim ersten wurde das Datum auch richtig dargestellt, nämlich in dem Format :
Tag Datum Monat Uhrzeit Jahr
aber beim heutigen Eintrag zeigte er :
Tag Monat Datum Uhrzeit und kein Jahr ?
Wie kann das sein ?
Hier der Teilausschnitt : http://www.acid4u.com/homepage4/news/news.cgi
So sieht der noch unformatierte Eintrag immer aus, bevor er vom Script ausgelesen wird:
Fri Jan 4 18:34:48 2002
5 neue Tapes zum downloaden und anhören.
Hier das Script : (Sicherheitshalber vollständig)
#!/usr/bin/perl -w
use CGI;
$query = new CGI;
$verzeichnis = '.';
@datum = ();
@textliste = ();
print $query->header;
opendir(DIR, "$verzeichnis") or die "Verzeichnis kann nicht geoeffnet werden : $!\n";
while ($file = readdir(DIR)) {
if ($file =~ /^\d+.txt/) {
push @unsortierte_liste, $file;
}
}
closedir DIR;
@dateiliste = sort { $b cmp $a } @unsortierte_liste;
foreach $file(@dateiliste) {
open (DATEI,"$verzeichnis/$file") or die "Konnte $file nicht oeffnen : $!\n";
@dateiinhalt = ();
@dateiinhalt = <DATEI>;
($erste_zeile, @textdaten) = @dateiinhalt;
$erste_zeile = $erste_zeile."\n";
foreach $zeile(@textdaten) {
$zeile =~ s/\n/<br>/;
push @neuer_inhalt, $zeile;
}
close DATEI;
$texte = join(' ',@neuer_inhalt);
@neuer_inhalt = ();
push @datum, $erste_zeile;
push @textliste, $texte;
}
print <<EOF;
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="expires" content="0">
<meta http-equiv="cache-control" content="no-cache">
<style type="text/css">
body {background-image:url(../iframe.jpg); background-attachment:fixed;
font-family:Arial Black; font-size:12px; color:#00f300;
scrollbar-base-color:#000000;
scrollbar-3dlight-color:#FFFFFF;
scrollbar-arrow-color:#00ff00;
scrollbar-darkshadow-color:#000000;
scrollbar-face-color:#00af00;
scrollbar-highlight-color:#FFFFFF;
scrollbar-shadow-color:#000000;
scrollbar-track-color:#000000;
}
#nr1 {font-family:Arial Black; font-size:12px; color:#00f300;position:relative;top:20px;left:20px}
#datum {font-family:Arial Black; font-size:12px; color:#00f300;position:relative;top:-140px;left:60px}
#text {font-family:Arial Black; font-size:12px; color:#00f300;position:relative;top:-110px;left:40px}
</style>
</head>
EOF
$i = 0;
foreach $volle_zeit(@datum) {
($tag, $monat, $datum, $zeit, $jahr) = split /\s/, $volle_zeit;
if ($tag eq 'Mon') {
$tag = 'Mon.';
}
elsif ($tag eq 'Tue') {
$tag = 'Di.';
}
elsif ($tag eq 'Wed') {
$tag = 'Mi.';
}
elsif ($tag eq 'Thu') {
$tag = 'Do.';
}
elsif ($tag eq 'Fri') {
$tag = 'Fr.';
}
elsif ($tag eq 'Sat') {
$tag = 'Sa.';
}
elsif ($tag eq 'Sun') {
$tag = 'So.';
}
if ($monat eq 'Jan') {
$monat = '01.';
}
elsif ($monat eq 'Feb') {
$monat = '02.';
}
elsif ($monat eq 'Mar') {
$monat = '03.';
}
elsif ($monat eq 'Apr') {
$monat = '04.';
}
elsif ($monat eq 'May') {
$monat = '05.';
}
elsif ($monat eq 'Jun') {
$monat = '06.';
}
elsif ($monat eq 'Jul') {
$monat = '07.';
}
elsif ($monat eq 'Aug') {
$monat = '08.';
}
elsif ($monat eq 'Sep') {
$monat = '09.';
}
elsif ($monat eq 'Oct') {
$monat = '10.';
}
elsif ($monat eq 'Nov') {
$monat = '11.';
}
elsif ($monat eq 'Dec') {
$monat = '12.';
}
@neue_zeit = ($tag.',', $datum.'. ', $monat.' ', $zeit.' ', $jahr);
$neue_zeit = join (' ', @neue_zeit);
print "<body bgcolor="black">\n";
print "<div id="nr1"><img src="news.png" width=500 height=200></div>\n";
print "<div id="datum">$neue_zeit</div>\n";
print "<table width=430 border="0"><td>\n";
print "<div id="text">$textliste[$i]</div>\n";
print "</td></table>\n";
$i++;
}
print "</body>\n</html>\n";
Hallo nochmal, nach langem heruntüfteln bin ich draufgekommen :
($tag, $monat, $datum, $zeit, $jahr) = split /\s/, $volle_zeit;
zu ->
($tag, $monat, $datum, $zeit, $jahr) = split /\s+/, $volle_zeit;
also ein einfaches + hat gefehlt.