in reply to Perl - Unique Numbers
1..20 creates an ordered list of numbers from 1 to 20. shuffle randomly orders the list. ()[0..9] is a slice which picks the 1st 10 numbers from the random list.use warnings; use strict; use List::Util qw(shuffle); for ((shuffle(1..20))[0..9]) { print "$_\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl - Unique Numbers
by bagyi (Acolyte) on Oct 18, 2015 at 04:22 UTC |