Randy, You are absolutely correct. Perl's rand function is not a random as it could be. List::Util (via Fisher-Yates) is definitely more "random." However, the original problem placed the contraint of not repeating any numbers. So with every number chosen, you invariably shrink the number of choices left.
I see this problem exactly like picking numbers for a lottery drawing. If there are 50 numbers (1-50) total and 6 winning numbers, after you choose the first number there are 49 left to choose from. After the second pick, there are 48 choices left, etc. I don't think anyone would suggest that a lottery drawing is not completely random.... Although conspiracies abound! The bottom line (or so I think) is that List::Util's algorithm for randomness is better (more random) than Perl's rand() function. Am I making sense? Thanks, Michael -----Original Message----- From: Randy W. Sims [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 27, 2004 6:21 AM To: Zeus Odin Cc: [EMAIL PROTECTED] Subject: Re: [SOLUTION] how can i generate 10 unique (non repeating) numbers Hmm, I may be wrong, but I don't think this is as random as it could be. The problem is that every time you remove an element from the list, you shrink the sample size. So the first selection is more random that the next, and that selection more random than the next, etc. A better approach is to perform a Fisher-Yates shuffle on the list and then pop N elements from the list. This is what List::Util does. Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>