Personally, I would put all the questions in a separate text file (or in the __DATA__ section of the Perl file, if you like to keep it in one file). Use a record separator of your choice and set $/ accordingly to read them one by one. This way, you'd have to write the code for presenting the questions, getting the reply, etc. only once (at least for a certain type of question, like multiple choice), instead of literally spelling out dozens of prints and ifs...
To indicate correct/incorrect choices, you might want to use different capitalisation (e.g. a. ... for incorrect, A. ... for correct), or indentation, that you extract out of the question text, but remove prior to presenting the question. That might make it easier than having/parsing a separate entry per question which indicates what's correct (just a suggestion...)
Storing the questions in an easily (human-)readable form would also have the added benefit that you can much more easily manage the set of questions in case of additions or updates.
In reply to Re: Best code approach for this goal
by almut
in thread Best code approach for this goal
by irvson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |