in reply to Random data generation.
#!/usr/bin/perl use strict; use warnings; my @random = (qw/a b c d e f/) x 2; foreach my $i (reverse 0..$#random) { my $r = int rand ($i+1); @random[$i, $r] = @random[$r, $i] unless ($i == $r); } print @random, "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Random data generation.
by BrowserUk (Patriarch) on Jun 27, 2010 at 15:11 UTC |