#! perl -sw use strict; sub shufl (\@) { my $r=pop; $a = $_ + rand @{$r} - $_ and @$r[$_, $a] = @$r[$a, $_] for (0..$#{$r}); } my @array = qw(the quick brown fox jumps over the lazy dog and went straight into a puddle); my @indexes = (0..$#array); shufl(@indexes); my ($comp1, $comp2, $comp3, $comp4, $comp5) = @array[@indexes[0..4]]; print"$comp1, $comp2, $comp3, $comp4, $comp5\n"; __END__ #Ouput C:\test>210389.pl jumps, dog, a, the, fox C:\test>210389.pl a, the, lazy, brown, into C:\test>210389.pl and, quick, a, puddle, fox C:\test>210389.pl a, and, the, the, into C:\test>210389.pl dog, jumps, went, the, straight C:\test>210389.pl lazy, quick, and, into, fox C:\test>210389.pl the, went, the, brown, over C:\test>