for (my $i = scalar(@list); --$i; ) { my $j = int rand ($i+1); next if $i == $j; @list[$i,$j] = @list[$j,$i]; }