Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Pig Latin

by Anonymous Monk
on Feb 17, 2000 at 02:16 UTC ( [id://3593]=note: print w/replies, xml ) Need Help??


in reply to Pig Latin

It depends on how general you want to be. My first run attempt is:

while(<>) { s{ \b([bcdfghjklmpqrstvwxyz]?)(\w+) } { if($1) {$2.$1.'ay'} else {$2."way"} }egix; print; }

The problem is that this doesn't correctly treat cases like th, sh, pr, etc. where there's really a compound starting consonant. Maybe, this would be a bit more correct:

while(<>) { s{ \b([bcdfghjklmpqrstvwxyz]*)([aeiou]+)(\w*) } { if($1) {$2.$3.$1.'ay'} else {$2.$3."way"} }egix; print; }

Replies are listed 'Best First'.
RE: (2) Pig Latin (another smidge closer)
by ybiC (Prior) on Jul 23, 2000 at 17:35 UTC
    Adding qu| at the front of $1 and removing q from [...] provides support for the "qu" combination.   My first attempted tweak was to add (qu) inside $1's [...] but that hosed things for words like "jumped".

    Bonus points for guessing the cliche phrase I tested this with.  <grin>

    #!/usr/bin/perl -w use strict; while(<>) { s{ \b(qu|[bcdfghjklmpnrstvwxyz]*)([aeiou]+)(\w*) } { if($1) {$2.$3.$1.'ay'} else {$2.$3."way"} }egix; print; } # END
        cheers,
        ybiC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://3593]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (None)
    As of 2024-04-25 04:25 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found