in reply to Array problem

use List::Util qw(shuffle); use strict; use warnings; my @start = qw( dog cat bird mouse rat snake horse cow pig lizard lamb + zebra lion elephant monkey ); my @a = shuffle @start; for ( 0 .. $#a ) { print "@a[ $_, ($_+1)%@a, ($_+3)%@a, ($_+6)%@a ]\n"; }

The nice thing about this is that it does exactly one shuffle, and never calls rand (except insided the shuffle).

Between the mind which plans and the hands which build, there must be a mediator... and this mediator must be the heart.

Replies are listed 'Best First'.
Re^2: Array problem
by ikegami (Patriarch) on Sep 29, 2008 at 00:40 UTC
    Caveat: That can't ever give the results the OP provided.