use POSIX qw/floor/; local $/= '==='; my @allquestions = ; my @questions; for (1..$maxcount){ my $idx = floor rand @allquestions; push @questions, splice @allquestions, $idx, 1; } return @questions; #### local $/= '==='; my @allquestions = ; my @questions; push @questions, splice @allquestions, rand @allquestions, 1 for (1..$maxcount) return @questions;