How about you just List::Util shuffle 1 to 15 and then splice the first 5:
#!/usr/bin/perl use Data::Dumper; use List::Util 'shuffle'; my @list = ( 1 .. 15 ); print Dumper( \@list ); my @shuffled = shuffle(@list); print Dumper( \@shuffled ); my @five = splice( @shuffled, 0, 5 ); print Dumper( \@five );
In reply to Re: random number generation.
by derby
in thread random number generation.
by newbio
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |