Thread
:
Best way to randomize a text list???
View Single Post
03-20-2005, 03:19 AM
bbe
Confirmed User
Join Date: Feb 2005
Posts: 110
#!/usr/bin/perl
# Read File
while (<>) {
push(foo, $_);
}
# Shuffle lines
srand;
for (0..$#foo) {
$r = rand($#foo+1);
($foo[$r], $foo[$_]) = ($foo[$_], $foo[$r]);
}
# Print it out
for (0..$#foo) {
print $foo[$_];
}
bbe
View Public Profile
Find More Posts by bbe