#!/usr/bin/perl # # (void) faq program # Harl/06/04/1999/GPL/1.0 # # First prints out html contained in header file. Then creates an index # based on available question and answer files. # # For each question make a subdirectory called void_faq_qx where x is # a number. Put the question into a file called question.txt in that # directory and the answers in seperate files. They can be called # anything as long as each filename is unique and has a .dat extension # # This has been a production by The Wrong People # $header_file = "header.dat"; # # Get random answer for current question # sub show_random_answer { $len = @the_masses = <$dir_name/*.dat>; $chosen_one = @the_masses[rand $len]; open(ANSWER, $chosen_one) or die "Can't open $chosen_one\n"; while () { print " "; print; } } # # Print header # #print "Content-type: text/html\n\n"; open(INTRO, $header_file) or die "Can't open $header_file\n"; while () { print; } # # Print index # print "

Contents

\n"; @dir_list = ; $q_num = 0; foreach $dir_name (@dir_list) { $q_num++; print " $q_num\) "; open(QUESTION, "$dir_name/question.txt"); $q_str = ; chomp $q_str; print $q_str; print "
\n"; } print "

\n


\n

\n"; # # Print full question and answer # $q_num = 0; foreach $dir_name (@dir_list) { $q_num++; print " \n"; print " Question $q_num
\n"; open(QUESTION, "$dir_name/question.txt"); $q_str = ; chomp $q_str; print " $q_str
\n"; show_random_answer; print "

\n\n"; } # # Print footer # print " \n"; print " \n"; print "\n";