
KevinR
Veteran

Sep 20, 2003, 5:01 PM
Post #2 of 5
(434 views)
|
|
Re: [andy7t] Randomising Arrays
[In reply to]
|
Can't Post
|
|
I don't know if there is a module already made for doing something like you want, but this will also work, its crude but effective :)
#!/perl/bin/perl.exe print qq~Content-type: text/html\n\n~; use strict; my @array = qw(Joe Fred Kevin John Paul Andy Mike Harry); my @new; @array = &randomize(@array); sub randomize { my $r_num = int(rand(int(@array))); push @new, $array[$r_num]; delete $array[$r_num]; &randomize if @array; return (@new); } print "@array"; -------------------------------------------------
|