my $num = shift; my @init = (0..$num-1); my @questions; while (<>) { $questions[splice @init, rand(@init), 1] = $_, next if $. <= $num; my $i = rand($.); $questions[$i] = $_ if $i < $num; }
In reply to Re: Re (tilly) 2 (unrandomness): Extract random records from text file
by runrig
in thread Extract random records from text file
by SuperCruncher
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |