in reply to Select three random numbers between 1..10

If you're filtering, you could get into a worst-case loop (particularly if you were picking nine out of ten numbers, or 99 out of a hundred).

A better method is something like this:

@arr=1..10; for (1..3) { $i=int(rand(scalar @arr)); push(@num,splice(@arr,$i,1)); } foreach my $num (@num){ print"$num\n"; }
At the cost of storing all the numbers you are likely to generate, this code guarantees that it will finish in time proportional to n (instead of time growing at the same rate as n/m where n is the number of numbers chosen, and m is the size of the set).