in reply to Where is the zero coming from?
I think you need to read the perldoc for the rand() function:
linux> perldoc -f rand
perl -e '@choices = qw|a b c d e|; print rand(@choices) . qq|\n|;' 0.785222268100387
It doesn't return a random element from your list.
Since your question reads so much like homework I'll leave you with this:
- Since rand() gives you a non-integer you need to turn it into an integer (read the perldoc)
- You only have 49 elements in your bucket of lotto balls -- how can you restrict the return value of rand() so that the greatest value it can produce is 49 (hint, you might try using a modulus)?
Celebrate Intellectual Diversity
In Section
Seekers of Perl Wisdom