my $suffix = 'ay';
# FIXME: does not handle:
- # punctuation and hyphens
- # y as vowel "style" -> "ylestay"
+ # 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)(.)(.*)/ ) {
} else {
$pigword = $word . 'w' . $suffix;
}
- $piglatin .= " $pigword";
+ $piglatin .= ' ' if $piglatin;
+ $piglatin .= $pigword . $postfix;
}
&::performStrictReply($piglatin||'failed');
}
1;
+
+# vim:ts=4:sw=4:expandtab:tw=80