The use of the tags hash has to do with the way I do template printing.
The item list has a variable $level which keeps track of the table of contents
level. Subitems are indented under their parents. When a non-subitem is encountered and the
$level is 1, then we have to terminate the sublevel.
$level = 0;
$tags{itemlist} = "<ul>\n";
foreach $item (@items) {
if (!$level && $parent{$item} ne '') {
$level = 1;
$tags{itemlist} .= "<ul>\n";
}
if ($level && $parent{$item} eq '') {
$level = 0;
$tags{itemlist} .= "</ul>\n";
}
$tags{itemlist} .= "<li> <a href=\"$url{$item}\">$label{$item}</a>\n";
}
$tags{itemlist} .= "</ul>\n";
$tags{objectlist} = "<ul>\n";
foreach $obj (@objects) {
$tags{objectlist} .= "<li> <code>$obj</code>:";
$tags{objectlist} .= "<a href=\"$url{$starter{$obj}}\">$label{$starter{$obj}}</a>\n";
}
$tags{objectlist} .= "</ul>\n";
|
%tags hash we used above to store our lists. We'll do the same thing again
for writing out our item pages.
open OUT, ">index.html";
open TEM, $index_html;
while (<TEM>) {
while (/\[##(.*?)##\]/) {
$tag=$1;
s/\[##$tag##\]/$tags{$tag}/e;
}
print OUT;
}
close TEM;
close OUT;
|
| This code and documentation are released under the terms of the GNU license. They are additionally copyright (c) 2000, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license. |