From: timriker Date: Thu, 24 Feb 2005 22:53:20 +0000 (+0000) Subject: trailing puntuation X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=5542758bdc88537ac2ef48258c9d83ae173d4938;p=infobot.git trailing puntuation git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1178 c11ca15a-4712-0410-83d8-924469b57eb5 --- 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'); }