Quote:
|
Originally Posted by Naughty
And what if you want to edit the text between the TITLE tags on the html page as well, and in php instead of perl?
|
It would take me a bit more time than I have right now to get it in PHP, so I modified it a bit in perl ..
in _template.html this will be your original file you start with, The title line needs to be: <title>%%TITLE%%</title>
In the filelist, which I called filename_list.txt, the file needs to look like this:
Code:
someword1.html||Title for someword1 file goes here
someword2.html||Title for someword2 file goes here
someword3.html||Title for someword3 file goes here
And so on ..
Here is the modified script .. going out for the rest of the day right now, didn't test it, but it should work....
Code:
#!/usr/local/bin/perl
$template = "_template.html";
$files = "filename_list.txt
open (TPL, $template);
@tpllines=<TPL>;
close(TPL);
open (FILE, $files);
@allfiles=<FILE>;
close(FILE);
foreach $list (@allfiles) {
chop($list);
($name,$title) = split(/||/, $list);
open (NEWFILE, ">${name}");
foreach $line (@tpllines) {
chop($line);
$line =~ s/%%TITLE%%/$title/;
print NEWFILE "$line\n";
}
close(NEWFILE);
}
exit;