]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Modules/scramble.pl
take a few more things literally
[infobot.git] / src / Modules / scramble.pl
index 5bbb597a806e359e96ec986a9ccd9d77f80d61f9..63161482979c6aae3c31f3b9ac24974ca47cde31 100644 (file)
@@ -12,13 +12,12 @@ use warnings;
 
 package scramble;
 
-use List::Util;
-
 sub scramble
 {
   my ($text) = @_;
   my $scrambled;
 
+  return unless &::loadPerlModule("List::Util");
   srand(); # fork seems to not change rand. force it here
   for my $orig_word (split /\s+/, $text)
   {
@@ -42,13 +41,12 @@ sub scramble
       {
        # non-random shuffle, but good enough
        ($new_middle = $middle) =~ s/(.)(.)/$2$1/g;
-       last;
       }
 
       # shuffle the middle letters
-      $new_middle = join "", List::Util::shuffle(split //, $middle);
+      $new_middle = join '', List::Util::shuffle(split //, $middle);
     }
-    while ($middle eq $new_middle);
+    while (($cnt < 10) && ($middle eq $new_middle));
 
     # add the word to the list...
     $scrambled .= "$first$new_middle$last ";
@@ -58,7 +56,7 @@ sub scramble
   # been included in the original string
   $scrambled =~ s/\s+$//;
 
-  &::pSReply($scrambled||"Unknown Error Condition");
+  &::performStrictReply($scrambled||'Unknown Error Condition');
 }
 
 1;