CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Pig Latin

 



MShareef
stranger

Oct 13, 2001, 12:29 PM

Post #1 of 2 (3032 views)
     Pig Latin  

I am trying to write a program that will convert an entered string/word into its pig latin form.
The rules of pig latin:
If the word starts with a vowel
than add way to the end
Otherwise everything from the beginning of the word upto (but not including) the first vowel(including 'y') is removed and added on to the end + "ay"

examples:
apple --> appleway
yellow --> ellowyay
bye --> yebay

* This is actually a pretty easy project, but there is one perk, I am trying to do this in as little code as possible(i.e. the number of characters in the perl script must be at a minimum)

Here is what I have so far
-------------------------------------------

while(<>) {
chomp;
if(/^[aeiou]/i){print"$_"."way\n"}
elsif(/^(?:(.+?)([aeiouy]))/i){print"$2$'$1ay\n"}
}

-------------------------------------------
Please reply if you know a way to shorten my code.
Thanks!!!!



rGeoffrey
User

Oct 15, 2001, 3:25 PM

Post #2 of 2 (3026 views)
     Re: Pig Latin [In reply to]  

With a few small modifications I have posted this in the Quiz forum. Please directy further comments there.

http://forums.perlguru.com/postlist.pl?Cat=&Board=Forum14&page=0&view=collapsed&sb=5


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives