
MShareef
stranger
Oct 13, 2001, 12:29 PM
Post #1 of 2
(12578 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!!!!
|