in reply to Re: Random Picks
in thread Random Picks
To not duplicate a pick you do a Fisher-Yates shuffle and stop after N steps:
- tye (but my friends call me "Tye")my @ssn= getAllSSNs(); my $want= 1000; for( 0..$want-1 ) { my $choice= $want + rand(@ssn-$want); @ssn[$_,$choice]= @ssn[$choice,$_]; } return @ssn[0..$want-1];
|
---|