Perl 'Expert' Quiz-of-the-Week #6

Mark Jason Dominus <[email protected]> Wed, 20 Nov 2002 17:46:49 -0500
Newsgroups gmane.comp.lang.perl.qotw.quiz-of-the-week
Organization Plover Systems
Message-ID <[email protected]>
IMPORTANT: Please do not post solutions, hints, or other spoilers
        until at least 60 hours after the date of this message.
        Thanks.

IMPORTANTE: Por favor, no enviéis soluciones, pistas, o cualquier otra
        cosa que pueda echar a perder la resolución del problema hasta
        que hayan pasado por lo menos 60 horas desde el envío de este
        mensaje. Gracias.

IMPORTANT: S'il vous plaît, attendez au minimum 60 heures après la
        date de ce message avant de poster solutions, indices ou autres
        révélations. Merci.

WICHTIG: Bitte schicken Sie keine Lösungen, Tipps oder Hinweise für
        diese Aufgabe vor Ablauf von 60 Stunden nach dem Datum dieser
        Mail. Danke.

Qing3 Zhu4Yi4: Qing3 Ning2 Deng3Dao4 Jie1Dao4 Ben3 Xin4Xi2 Zhi1Hou4 60
        Xiao3Shi2, Zai4 Fa1Biao3 Jie3Da2, Ti2Shi4, Huo4 Qi2Ta1 Hui4
        Xie4Lou4 Da2An4 De5 Jian4Yi4.  Xie4Xie4.



----------------------------------------------------------------

Write a generic survey or quiz program, "survey".

The program will read a configuration file in this format:

        How old are you?  0-12; 13-19; 20-24; 25-34; 35-44; 45 or older
        What is your favorite color?  red; blue; black; other
        ...

Each question is on a separate line; the question is everything up to
and including the first '?', and the allowed responses to the question
are the following items separated by ';'.  If the last response ends
with ";;" instead of ";", any data following the ";;" is taken to be
configuration options for that question, separated by spaces.  For
example:

    How old are you?  0-12; 13-19; 20-24; 25-34; 35-44; 45 or older;; OPTIONAL
    What is your favorite color?  red; blue; black;; ALLOW_OTHER

It is up to you to decide what options, if any, should be supported.

The program will then prompt the user with the questions, and read and
validte the responses.  When the user has finished answering the
questions, the program should record the responses in a file.

There should be some way to run the program to get it to disgorge a
report about the aggregate survey responses.  The report should
include: The number of people completing the survey; the number
providing each response to each question, and the percentage breakdown
for the responses to each question.

The program could use the terminal as an interface, or it could have a
Tk interface, or could be a CGI program, or whatever you prefer.