Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: How could I create a command line quiz?

by yasser (Initiate)
on Mar 12, 2020 at 16:06 UTC ( [id://11114181]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How could I create a command line quiz?
in thread How could I create a command line quiz?

Yes, you're right. I want to get the structure of the script correct first and then I'll replace the backticks with perl code

I've built up to this part slowly by testing a basic subroutine that outputs static values, then added more functionality as my knowledge builds.

  • Comment on Re^3: How could I create a command line quiz?

Replies are listed 'Best First'.
Re^4: How could I create a command line quiz?
by soonix (Canon) on Mar 13, 2020 at 07:34 UTC
    the structure of the script
    Hmm. You seem to do
    1. read the list of questions in
    2. print the first question
    3. read the list of answers
    4. print the first answer
    Now, how would you go for a random question, considering that there can be multiple answers for a question?
    1. read the list of questions in - ok
    2. print a random question - ok
    3. read the list of answers - ok
    4. print … which answer???
    Better control flow would be:
    1. read the list of questionss and answers, preserving the relation between q and a
    2. select a random q&a group
    3. print the selected question
    4. print the corresponding answers
    Problem: you need a structure, yes, but not only of the script (control flow) but also for your data (be that arrays or objects). That might be possible with bash and grep, but that will be very specific and therefore difficult to translate to any other language, including Perl

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11114181]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-20 06:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found