#!/usr/bin/perl $LongerName{admin} = "Administration"; $LongerName{config} = "Configuration/Setup"; $LongerName{config} = "How does ..."; chdir("data"); foreach $f (<*.html>) { next if ($f eq "index.html"); open(CONTENTS, "<$f") || die "Cannot open $f\n"; my($Contents) = join(' ', ); close(CONTENTS); $Grouping = $1 if ($Contents =~ /Grouping:\s*(\S+)/i); $Contents =~ s/\n/ /g; $Contents =~ s/\s*\<\/h2\>.*//; $Contents =~ s/.*\\s*//; $Contents =~ s/^\s*\d+\s*:\s*//; print "Processing $f:\n\t$Contents\n"; $Questions{$f} = $Contents; $Groups{$Grouping} .= (($Groups{$Grouping} eq "") ? "" : ",") . $f; } open(INDEXFILE, ">index.html") || die "Cannot open index.html\n"; print INDEXFILE "

FAQs taken from Customer Support calls

\n"; foreach $g (sort keys %Groups) { if ($LongerName{$g} eq "") { print INDEXFILE "

$g

\n"; } else { print INDEXFILE "

$LongerName{$g}

\n"; } print INDEXFILE "\n"; foreach $q (split(",", $Groups{$g})) { print INDEXFILE "
  • \n"; print INDEXFILE " $Questions{$q}\n"; print INDEXFILE "
  • \n"; } print INDEXFILE "
    \n"; } close(INDEXFILE); print "Done!\n";