in reply to How to not print the same random number
@arr = 1..10; randomize(\@arr); print "@arr"; sub randomize { my ($p, $size, $swap, $key); $p = $_[0]; $size = $#$p; for (0..($size-1)) { $swap = int rand($size - $_ + 1) + $_; $key = $p->[$_]; $p->[$_] = $p->[$swap]; $p->[$swap] = $key; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to not print the same random number
by GrandFather (Saint) on Mar 05, 2006 at 21:17 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |