As an absolute beginner at this language, i am stuck
on what is probably so simple i'll kick myself for not
seeing it.
I am learning (trying!) from Ellie Quigley's Perl by
Example 4th Ed.
One exercise asks the programmer to build a deck of
cards (easy!).
My hitch is in trying to get 10 cards at random. I can get ten cards but, they are all the same card.
How does one get random subscripts with each iteration
of the loop?
Second half of prog:
foreach $i (1..10) {
$card = $deck[randdeck];
print "Card $i is the $card";
}
What am I overlooking?
__________________________________________________________
Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs
>>>>> "Donald" == Donald Korrecta < draktrax%40yahoo.com">draktraxyahoo.com> writes:
Donald> I can get ten cards but, they are all the same card.
Your code wouldn't get the same card each time. Maybe you mean
"sometimes I get the same card".
Unless somehow you have only one card in deck.
So perhaps you could post the code that has the behavior above,
or confirm the other two things I just said. Also show
how you initializedeck.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
< merlyn%40stonehenge.com">merlynstonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!