1 # turns english text into piglatin
2 # Copyright (c) 2005 Tim Riker <Tim@Rikers.org>
15 # FIXME: does not handle:
16 # non-trailing punctuation and hyphens
17 # y as vowel "style" -> "ylestay"
19 for my $word (split /\s+/, $text) {
20 my ($pigword, $postfix);
21 #($word,$postfix) = $word =~ s/^([a-z]*)([,.!\?;:'"])?$//i;
22 if ($word =~ s/([,.!\?;:'"])$//i) {
25 if ($word =~ /^(qu)(.*)/ ) {
26 $pigword = "$2$1$suffix";
27 } elsif ($word =~ /^(Qu)(.)(.*)/ ) {
28 $pigword = uc($2) . $3 . lc($1) . $suffix;
29 } elsif ($word =~ /^([bcdfghjklmnpqrstvwxyz]+)(.*)/ ) {
30 $pigword = "$2$1$suffix";
31 } elsif ($word =~ /^([BCDFGHJKLMNPQRSTVWXYZ])([bcdfghjklmnpqrstvwxyz]*)([aeiouy])(.*)/ ) {
32 $pigword = uc($3) . $4 . lc($1) . $2 . $suffix;
34 $pigword = $word . 'w' . $suffix;
36 $piglatin .= ' ' if $piglatin;
37 $piglatin .= $pigword . $postfix;
39 &::performStrictReply($piglatin||'failed');