Nicholas G. Thornton asked: > I was wondering how I would go aboput randomly ordering N number of > things. I'm running an experiment and I want to randomize the order > things appear in.
I'm pretty sure that the subroutine in the following is lifted directly from the Perl Cookbook (which is highly recommended if you don't already have it). Unfortunately my copy's at home, so I can't check the details. Cheers, Paul --------------------------------------------------------------- #!/usr/bin/perl -w use strict; my @things = qw(one two three and a bit); shuffle([EMAIL PROTECTED]); # shuffle the list in place print join "\n",@things; # fisher_yates shuffle: randomly permute lines in @list sub shuffle { my $array = shift; my $i; for ($i = @$array; --$i; ) { my $j = int rand ($i+1); next if $i == $j; @$array[$i,$j] = @$array[$j,$i]; } }