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"; }