in reply to Re: Pick k numbers at randomin thread Pick k numbers at random
my %remap; my @result; while ($K--) { my $x= int rand $N--; push @result, $remap{$x} // $x; $remap{$x}= $N; } [download]