]> git.donarmstrong.com Git - infobot.git/commitdiff
trailing puntuation
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 24 Feb 2005 22:53:20 +0000 (22:53 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 24 Feb 2005 22:53:20 +0000 (22:53 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@1178 c11ca15a-4712-0410-83d8-924469b57eb5

blootbot/src/Modules/piglatin.pl

index 07d17b8acbff06221789c82ff238bd4581a4cfc6..d15135bd72792e258bd5c93c1f6763871ff7b5bf 100644 (file)
@@ -13,11 +13,15 @@ sub piglatin
   my $suffix = 'ay';
 
   # FIXME: does not handle:
-  #  punctuation and hyphens
+  #  non-trailing punctuation and hyphens
   #  y as vowel "style" -> "ylestay"
   #  contractions
   for my $word (split /\s+/, $text) {
-    my $pigword;
+    my ($pigword, $postfix);
+    #($word,$postfix) = $word =~ s/^([a-z]*)([,.!\?;:'"])?$//i;
+    if ($word =~ s/([,.!\?;:'"])$//i) {
+      $postfix = $1;
+    }
     if ($word =~ /^(qu)(.*)/ ) {
       $pigword = "$2$1$suffix";
     } elsif ($word =~ /^(Qu)(.)(.*)/ ) {
@@ -30,7 +34,7 @@ sub piglatin
       $pigword = $word . 'w' . $suffix;
     }
     $piglatin .= ' ' if $piglatin;
-    $piglatin .= $pigword;
+    $piglatin .= $pigword . $postfix;
   }
   &::performStrictReply($piglatin||'failed');
 }