in reply to A little math

sub random_number { return (1..5)[rand 5]; }

Or just:

sub random_number { return 1 + int rand 5; }



answer($user_answer);

There is no  answer sub in your code.

Replies are listed 'Best First'.
Re^2: A little math
by Lady_Aleena (Priest) on Feb 21, 2011 at 16:49 UTC

    Thanks for catching the problem with the answer versus math_answer when it should recurse. You are also right about the rand, I overcomplicated it.

    Have a cookie and a very nice day!
    Lady Aleena