The full script is as follows:
my @pop = (1..100); my $samples = 30; my @sample = rand_samp(30,@pop); print "@sample"; sub rand_samp { my ($n,@n) = (shift,@_); return 0 unless ($n < scalar @n);# see note below my %seen = (); until (keys %seen == $samples) { $seen{$pop[rand @pop]}=1; } return(keys %seen); }
In reply to Re^2: Non-Repetitive Random Numbers
by Anonymous Monk
in thread Non-Repetitive Random Numbers
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |