1 # turns english text into piglatin
2 # Copyright (c) 2005 Tim Riker <Tim@Rikers.org>
14 # FIXME: does not handle:
15 # non-trailing punctuation and hyphens
16 # y as vowel 'style' -> 'ylestay'
18 for my $word ( split /\s+/, $text ) {
19 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";
28 elsif ( $word =~ /^(Qu)(.)(.*)/ ) {
29 $pigword = uc($2) . $3 . lc($1) . $suffix;
31 elsif ( $word =~ /^([bcdfghjklmnpqrstvwxyz]+)(.*)/ ) {
32 $pigword = "$2$1$suffix";
35 /^([BCDFGHJKLMNPQRSTVWXYZ])([bcdfghjklmnpqrstvwxyz]*)([aeiouy])(.*)/
38 $pigword = uc($3) . $4 . lc($1) . $2 . $suffix;
41 $pigword = $word . 'w' . $suffix;
43 $piglatin .= ' ' if $piglatin;
44 $piglatin .= $pigword . $postfix;
46 &::performStrictReply( $piglatin || 'failed' );
51 # vim:ts=4:sw=4:expandtab:tw=80