Hi,
I'm using some basic perl to write out a text file, containing sequential lines of information:
log.txt:
info1: data 1: blah; data 2: blah
info2: data 1: blah; data 2: blah
info3: data 1: blah; data 2: blah
etc
etc
I'm then using a shtml 'wrapper' to display the data in a browser:
log.shtml:
<html>
<head>
<title>
log
</title>
</head>
<body>
<small>
<!--#include file="log.txt" -->
</small>
</body>
</html>
I'm using Dan Steinman's site search script at
http://www.dansteinman.com/
to index & provide a search tool for the entire site, including the log file.
Problem is, it doesn't seem to want to index either any .txt files, or follow anything produced via an
<!--#include--> directive.
So, i'd like to do away with the
perl -> .txt file -> include .txt file in .shtml file
method, and just edit a plain .html file, preserving the ending tags whilst adding lines of data just before </body></html>.
What I can't figure out, is how to use perl to insert a line of data not totally at the end of the .html file, but rather, before the ending </body></html> tags.
If I just use >> in perl to just do an 'append' each time data comes along, I get:
.
.
.
data
</body></html> (original file)
data
</body></html> (result of first data write)
data
</body></html> (result of 2nd data write)
etc
Should I try & parse the whole existing file, write to a temporary file, and overwrite back to the original file, adding in the new line of data in the process, or is there a better way of 'inserting' data lines? Either way, I'd really appreciate any tips on how to do it...
Sorry to ramble but my head hurts and none of my beginners' books are helping much!
Cheers, Neil
I'm using some basic perl to write out a text file, containing sequential lines of information:
log.txt:
info1: data 1: blah; data 2: blah
info2: data 1: blah; data 2: blah
info3: data 1: blah; data 2: blah
etc
etc
I'm then using a shtml 'wrapper' to display the data in a browser:
log.shtml:
<html>
<head>
<title>
log
</title>
</head>
<body>
<small>
<!--#include file="log.txt" -->
</small>
</body>
</html>
I'm using Dan Steinman's site search script at
http://www.dansteinman.com/
to index & provide a search tool for the entire site, including the log file.
Problem is, it doesn't seem to want to index either any .txt files, or follow anything produced via an
<!--#include--> directive.
So, i'd like to do away with the
perl -> .txt file -> include .txt file in .shtml file
method, and just edit a plain .html file, preserving the ending tags whilst adding lines of data just before </body></html>.
What I can't figure out, is how to use perl to insert a line of data not totally at the end of the .html file, but rather, before the ending </body></html> tags.
If I just use >> in perl to just do an 'append' each time data comes along, I get:
.
.
.
data
</body></html> (original file)
data
</body></html> (result of first data write)
data
</body></html> (result of 2nd data write)
etc
Should I try & parse the whole existing file, write to a temporary file, and overwrite back to the original file, adding in the new line of data in the process, or is there a better way of 'inserting' data lines? Either way, I'd really appreciate any tips on how to do it...
Sorry to ramble but my head hurts and none of my beginners' books are helping much!
Cheers, Neil