in reply to Creating an array of unique numbers

There are certainly ways to do what you are trying to do, but it is much simpler to put all the questions into an array, then randomize that array, and pop or shift X number of questions off of it.

As far as generating X unique numbers, try this:

my $max = 10; my $num = 5; my %numhash; for (1 .. $num) { my $randnum = int(rand($max) + 1); redo if exists ($numhash{$randnum}); $numhash{$randnum} = 1; } for (keys (%numhash)) { print "$_\n"; }