From 5542758bdc88537ac2ef48258c9d83ae173d4938 Mon Sep 17 00:00:00 2001
From: timriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Date: Thu, 24 Feb 2005 22:53:20 +0000
Subject: [PATCH] trailing puntuation

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1178 c11ca15a-4712-0410-83d8-924469b57eb5
---
 src/Modules/piglatin.pl | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/Modules/piglatin.pl b/src/Modules/piglatin.pl
index 07d17b8..d15135b 100644
--- a/src/Modules/piglatin.pl
+++ b/src/Modules/piglatin.pl
@@ -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');
 }
-- 
2.39.5