Pig latin function, written as a small demo for s/// operators. Doesn't work for things like contractions, but hey, life isn't perfect.
{ my $notvowel=qr/[^aeiou_]/i; sub igpay_atinlay { local $_=shift; s[(\w+)] { local $_=$1; s/^($notvowel+)(.*)/$2$1ay/ or s/$/yay/; $_; }ge; $_; } }

Replies are listed 'Best First'.
Re: Pig Latin
by danger (Priest) on Mar 13, 2001 at 12:13 UTC

    For other versions see this node of the same title. Also, there is a module that implements pig latin (there is a module for practically everything ... practical or not :-):

    #!/usr/bin/perl -w use strict; use Text::Bastardize; $_ = "Hey don't it work fine"; my $latin = Text::Bastardize->new(); $latin->charge($_); print $latin->pig(),"\n";

    That module performs other useful transformations like; rot13, censor, and k3wlt0k as well.

Re: Pig Latin
by Adam (Vicar) on Mar 13, 2001 at 11:35 UTC
    Nice. Here is my attempt:
    s/([^aeiou_]+|)(\w*)(\s?)/$2&&$2.($1?$1:'y').'ay '/ige

    Beware of bugs in the above code; I have only proved it correct, not tried it.
    -- March 22, 1977, Donald E. Knuth