Hello List, Long time reader, first time poster. I have created a script that will generate 10 random numbers between 1 and 50. The numbers are assigned to variables in order from one to ten. The variables are $random_one_a, $random_two_a, $random_three_a and so on all the way to $random_ten_a. Here's the script for that:
$random_one_a = int(rand(49))+1; $random_two_a = int(rand(49))+1; $random_three_a = int(rand(49))+1; $random_four_a = int(rand(49))+1; $random_five_a = int(rand(49))+1; $random_six_a = int(rand(49))+1; $random_seven_a = int(rand(49))+1; $random_eight_a = int(rand(49))+1; $random_nine_a = int(rand(49))+1; $random_ten_a = int(rand(49))+1; So the computer might generate the following numbers: 30, 10, 5, 6, 20, 49, 50, 2, 4, 12 That means that: $random_one_a = 30 $random_two_a = 10 $random_three_a = 5 so on and so on.... I then assign all the variables to an array: @numbers_a = ("$random_one_a", "$random_two_a", "$random_three_a", "$random_four_a", "$random_five_a", "$random_six_a", "$random_seven_a", "$random_eight_a", "$random_nine_a", "$random_ten_a"); Then I sort them to get them in ascending order: @sorted_a = sort{$a<=>$b}(@numbers_a); I can then print out the @sorted_a array and the numbers appear on the screen in order from lowest to highest. The problem comes next. I want to take those ten numbers in ascending order and assign them to variables again (from lowest to highest. Here's what my script looks like: foreach $anumber (@sorted_a) { @sorted_field = split (/,/, $anumber); $randomonea = $sorted_field[0]; $randomtwoa = $sorted_field[1]; $randomthreea = $sorted_field[2]; $randomfoura = $sorted_field[3]; $randomfivea = $sorted_field[4]; $randomsixa = $sorted_field[5]; $randomsevena = $sorted_field[6]; $randomeighta = $sorted_field[7]; $randomninea = $sorted_field[8]; $randomtena = $sorted_field[9]; } This should assign $randomonea to the number 2, $randomtwoa to the number 4, $randomthreea to the number 5 so on and so on. The only number that shows up when I print these newly assigned variables is the highest number. For this example, if I printed out all of these newly assigned variables the only thing that would appear would be: $randomonea = 49 The rest of the variables show up as nothing. Not even 0's. My questions are: 1) Why does it take the first newly assigned variable $randomonea (which should be the lowest number) and give it a value of the highest number in the array? 2) Why don't the other nine values in the array show up as being assigned to the new variables? 3) Is this problem in my sorting or is it the actual assigning of the array members? If you would like to see the entire code please email me. I don't want to include it for obvious email cosmetic reasons. Thank you all in advance, Roger Spears -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]