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];
In reply to (tye)Re: Random Picks
by tye
in thread Random Picks
by lestad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |