Im writting a script that first displays all the poem files in a directory by their title inside the file. Each file starts off by the poem title and has a pipe '|' after it to parse with. The script is suppost to first come up with a list of all the poem titles gotten from the files. It links to call itself to display the poem once clicked.
The script shoes the files up top so you can compare what its showing to what is actually.
Heres the script uploaded and note carefully what it does: http://www.arcnemisis.f2s.com/playstuff/showdir.cgi
Heres the main part:
if($ENV{'QUERY_STRING'} eq '') {
### display poem titles.
opendir(DIR, ".");
@files = sort(grep(/shtml$/, readdir(DIR)));
closedir(DIR);
$FilesFound = @files;
foreach (@files)
{
print(" <a href='$_'> $_ </a> ");
}
print<<EOF;
<table width="600" bgcolor="FFFFFF" border="0">
<tr><td>
EOF
foreach (@files) {
@POEM = NULL;
$TEMP = $_;
open(FILE,"<$TEMP") or goterror("Unable to read $TEMP.");
while(<FILE>) {
@POEM = split(/\|/, $_);
}
close(FILE);
print("<br><a href='showdir.cgi?$TEMP'>$POEM[0]</a><br>");
}
print<<EOF;
</td></tr></table><br>
EOF
} #Endif
else {
### Display particular poem.
$FILENAME = $ENV{'QUERY_STRING'};
print("The file is $FILENAME");
print<<EOF;
<table width="600" bgcolor="FFFFFF" border="0">
<tr><td>
EOF
open(FILE,"<$FILENAME") or goterror("Unable to read $FILENAME.");
while(<FILE>) {
@POEM = split(/\|/, $_);
}
close(FILE);
print($POEM[0]);
print($POEM[1]);
print<<EOF;
</td></tr></table><br>
EOF
} #endelse
Someone please tell me why its not doing as it should.. ive tried for hours and I can spot it.
Thanks.
The script shoes the files up top so you can compare what its showing to what is actually.
Heres the script uploaded and note carefully what it does: http://www.arcnemisis.f2s.com/playstuff/showdir.cgi
Heres the main part:
if($ENV{'QUERY_STRING'} eq '') {
### display poem titles.
opendir(DIR, ".");
@files = sort(grep(/shtml$/, readdir(DIR)));
closedir(DIR);
$FilesFound = @files;
foreach (@files)
{
print(" <a href='$_'> $_ </a> ");
}
print<<EOF;
<table width="600" bgcolor="FFFFFF" border="0">
<tr><td>
EOF
foreach (@files) {
@POEM = NULL;
$TEMP = $_;
open(FILE,"<$TEMP") or goterror("Unable to read $TEMP.");
while(<FILE>) {
@POEM = split(/\|/, $_);
}
close(FILE);
print("<br><a href='showdir.cgi?$TEMP'>$POEM[0]</a><br>");
}
print<<EOF;
</td></tr></table><br>
EOF
} #Endif
else {
### Display particular poem.
$FILENAME = $ENV{'QUERY_STRING'};
print("The file is $FILENAME");
print<<EOF;
<table width="600" bgcolor="FFFFFF" border="0">
<tr><td>
EOF
open(FILE,"<$FILENAME") or goterror("Unable to read $FILENAME.");
while(<FILE>) {
@POEM = split(/\|/, $_);
}
close(FILE);
print($POEM[0]);
print($POEM[1]);
print<<EOF;
</td></tr></table><br>
EOF
} #endelse
Someone please tell me why its not doing as it should.. ive tried for hours and I can spot it.
Thanks.