sub anagram { my $orig=shift; $word=join("",sort(split(//,$orig))); #Got to be a better way! my $anagram=$word; do { $anagram=""; for (0..length $word) { if (rand(1)<0.5) #Tag letter onto end or start? { $anagram.=substr($word,$_,1); } else { $anagram=substr($word,$_,1).$anagram; } } } while ($anagram eq $orig); #Make sure it's not the same. return $anagram; #Woo! }
In reply to Create anagrams simply by Darkling
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |