in reply to Re^2: Control Structure problem, mistake can't be found
in thread Control Structure problem, mistake can't be found

Let's take it a little bit at a time:

my @quiz = (...);

initializes an array from a list.

{...}

generates a reference to a hash. A reference is a "handle" that you can use to refer to something else. So:

my @quiz = ({...}, {...}, {...});

generates an array containing references to three hashes. Each hash is of the form:

{ask => "...", answer => "..."}

The => is the "fat comma". It's exactly like an ordinary comma, except that it pretends the (non-white space) sequence of characters to its left has quotes around it. ask => "..." is the same as 'ask', "...". The fat comma is a handy way of generating a list to initialize a hash and is often used as a heads up to indicate that two items in a list are a pair.

The intent is to generate a data structure comprised of an array containing a list of hashes where each hash represents a question and answer pair. Other information could be added to each hash such as a weighting for the question (so harder questions are worth more) for example:

my @quiz = ( {ask => "Name the definitive rock band..", answer => "The Rolling Stones", value => 10, }, {ask => "What is their best song?", answer => "Moonlight Mile" value => 20, }, {ask => "What is their best album?", answer => "Sticky Fingers" value => 5, }, );

Perl reduces RSI - it saves typing