From bc8098bd96b4cd0e18f82e99100dde4eacde1018 Mon Sep 17 00:00:00 2001 From: timriker 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@1178 c11ca15a-4712-0410-83d8-924469b57eb5 --- blootbot/src/Modules/piglatin.pl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/blootbot/src/Modules/piglatin.pl b/blootbot/src/Modules/piglatin.pl index 07d17b8..d15135b 100644 --- a/blootbot/src/Modules/piglatin.pl +++ b/blootbot/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