<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">use utf8;
package FAQ;

my ($faq,$var,$env,$q,$a,$c,$s,$t,$n);
my (@faq,%Q,%A,@s);
my @sections = qw'Meta User Admin Misc';

@faq = ($faq) = $ENV{PATH_INFO} =~ /(\w+).html/;
@faq = map {lc} @sections if $faq eq 'all';

print "&lt;style type=text/css&gt;&lt;!-- h2,h3 {font-weight:normal} --&gt;&lt;/style&gt;\n";

print '&lt;h1&gt;&lt;a name="top" href="/index.html"&gt;F*EX&lt;/a&gt; ';
printf "Frequently Asked Questions: %s&lt;/h1&gt;\n",ucfirst($faq);

if ($faq ne 'local') {
  print "&lt;h3&gt;Sections: ";
  foreach $s (@sections,'All') {
    if ($s =~ /$faq/i) {
      print "&lt;b&gt;$s&lt;/b&gt;\n";
    } else {
      printf "[&lt;a href=\"%s.html\"&gt;%s&lt;/a&gt;]\n",lc($s),$s;
    }
  }
  print "&lt;/h3&gt;\n";
}

print "&lt;p&gt;&lt;hr&gt;&lt;p&gt;\n";
print "&lt;table&gt;\n";

foreach my $faq (@faq) {
  open $faq,"$faq.faq" or next;
  local $/ = "Q:";
  local $_ = &lt;$faq&gt;;
  while (&lt;$faq&gt;) {
    chomp;
    while (/\$([\w_]+)\$/) {
      $var = $1;
      $env = $ENV{$var} || '';
      # s/\$$var\$/&lt;code&gt;$env&lt;\/code&gt;/g;
      s/\$$var\$/$env/g;
    };
    ($q,$a) = split /A:\s*/;
    $q =~ s/[\s\n]+$//;
    $q =~ s/^\s+//;
    $q =~ s! (/\w[\S]+/[\S]+)! &lt;code&gt;$1&lt;/code&gt;!g;
    $a =~ s/[\s\n]+$/\n/;
    $a =~ s/^\s+//;
    while ($a =~ s/^(\s*)\*/$1&lt;ul&gt;\n$1&lt;li&gt;/m) { 
      while ($a =~ s/(&lt;li&gt;.*\n\s*)\*/$1&lt;li&gt;/g) {}
      $a =~ s:(.*\n)(\s*)(&lt;li&gt;[^\n]+\n):$1$2$3$2&lt;/ul&gt;\n:s
    }
    $a =~ s/\n\n/\n&lt;p&gt;\n/g;
    $a =~ s/([^&gt;\n\\])\n/$1&lt;br&gt;\n/g;
    $a =~ s/&lt;pre&gt;(.+?)&lt;\/pre&gt;/pre($1)/ges;
    $a =~ s/\\\n/\n/g;
#    $a =~ s/^\s*&lt;br&gt;\s*//mg;
    $a =~ s/&lt;([^\s&lt;&gt;\@]+\@[\w.-]+)&gt;/&lt;a href="mailto:$1"&gt;&amp;lt;$1&gt;&lt;\/a&gt;/g;
    $a =~ s! (/\w[\S]+/[\S]+)! &lt;code&gt;$1&lt;/code&gt;!g;
    $a =~ s!(https?://[\w-]+\.[^\s&lt;&gt;()]+)!&lt;a href="$1"&gt;[$1]&lt;/a&gt;!g or
    $a =~ s!(https?://[^\s&lt;&gt;()]+)!&lt;code&gt;$1&lt;/code&gt;&lt;/a&gt;!g;
    push @{$Q{$faq}},$q;
    push @{$A{$faq}},$a;
  }
  close $faq;
}

print "&lt;table&gt;\n";

foreach $s (sections($faq)) {

  $c = lc $s;
  $s = '' if $s eq 'Local';
  $t = '';
  $t = $s if $faq eq 'all';

  for ($n = 0; $n &lt; scalar(@{$Q{$c}}); $n++) {
    $q = ${Q{$c}[$n]};
    $qa = anchor($q);
    printf '&lt;tr valign=top&gt;&lt;th align=left&gt;'.
           '&lt;a href="#%s%d" style="text-decoration: none"&gt;'.
           '&lt;font color="black"&gt;%s&amp;nbsp;Q%d&lt;/a&gt;:'.
           '&lt;td&gt;&lt;a href="#%s"&gt;%s&lt;/a&gt;&lt;/tr&gt;'."\n",
           $t,$n+1,$s,$n+1,$qa,$q;
  }
}

print "&lt;/table&gt;\n";
print "&lt;p&gt;&lt;hr&gt;&lt;p&gt;\n";

foreach $s (sections($faq)) {

  $c = lc $s;
  $s = '' if $s eq 'Local';
  $t = '';
  $t = $s if $faq eq 'all';

  for ($n = 0; $n &lt; scalar(@{$Q{$c}}); $n++) {
    $q = ${Q{$c}[$n]};
    $qa = anchor($q);
    print "&lt;p&gt;\n";
    print "&lt;table&gt;\n";
    printf "&lt;tr valign=top&gt;&lt;th&gt;".
           "&lt;a name=\"%s%d\"&gt;%s&amp;nbsp;Q%d:&lt;/a&gt;".
           "&lt;a name=\"%s\"&gt;&lt;/a&gt;".
           "&lt;td&gt;&lt;b&gt;%s&lt;/b&gt;&lt;/tr&gt;\n",
           $t,$n+1,$s,$n+1,$qa,$q;
    printf "&lt;tr valign=top&gt;&lt;th&gt;%s&amp;nbsp;A%d:&lt;td&gt;\n%s&lt;/tr&gt;\n",
           $s,$n+1,${A{$c}[$n]};
    print "&lt;/table&gt;\n";
    print "[&lt;a href=\"#top\"&gt;&amp;uarr;&amp;nbsp;Questions&lt;/a&gt;]\n";
  }
}

print "&lt;pre&gt;\n";
print "\n" x 99;
print "&lt;/pre&gt;\n";


sub sections {
  my $faq = shift;
  if ($faq eq 'all') {
    return @sections;
  } else {
    return ucfirst($faq);
  }
}

sub pre {
  local $_ = shift;
  s/&lt;br&gt;//g;
  s/\s+$//;
  return "&lt;pre&gt;$_&lt;/pre&gt;\n";
}

sub anchor {
  local $_ = shift;
  s/&lt;.+?&gt;//g;
  s/\(.+?\)//g;
  s/\W/_/g;
  s/_+$//;
  return $_;
}
</pre></body></html>