my (%rec) = @_;
($db_auto_generate and print &build_html_record(%rec) and return); #do I really need this line?
if ($rec{'category'} ne $prev_cat) {
$prev_cat = $rec{'category'};
print qq|<h2>|;
eval "html_record_$rec{'category'}_title(%rec)";
print qq|</h2><ul>|;
}
print qq|<li>|;
eval "html_record_$rec{'category'}(%rec)";
&html_record_end(%rec);
print qq|</ul>|;
}
If the record is the first one of its category, the sub prints the heading plus <ul>. If not, it doesn't.
In both cases, the sub then prints the search results (the </li>-tag is contained in sub html_record_end).
As it stands now, the sub then also prints </ul>. If there's only one record for category "article", this is just as well. If there's a second record, the sub will, without printing the heading (that contains the <ul>-tag), still print a </ul> at the end.
I know that this is stupid, but don't know what to change. I suppose some code that checks whether the next record has the same value in $rec{'category'} as the current one would be needed at the very end: If so, don't close the list; if not, close it.
Or maybe a loop in the beginning: If this is the first search result, print heading. If it isn't, and if ($rec{'category'} ne $prev_cat), print </ul> plus the heading.
kellner