#!/usr/bin/perl my $chars = "UDFBLR2'"; my ($result,$b,$rand); my $a = 6; my @check = (1,0,3,2,5,4); for (my $i; $i < 20000; $i++) { $rand = int(rand(6)); while ($rand == $a || ($rand == $b && $check[$rand] == $a)) { $rand = int(rand(6)); } $b = $a; $a = $rand; $result .= substr($chars,$rand,1); $rand = int(rand(3)); if ($rand) { $result .= substr($chars,$rand+5,1); } $result .= " "; } print "$result\n";