http://qs321.pair.com?node_id=302916

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am a beginner who is lost. Need to write a pig latin translator, but can't figure out how to parse the words apart and then manipulate them. Can someone point me in the right direction? Explain how to do it?

20031029 Edit by castaway: Changed title from 'beginner in desperate need of help'

Replies are listed 'Best First'.
Re: Pig latin translation
by BUU (Prior) on Oct 29, 2003 at 08:43 UTC
    Bearing in mind the possible homework nature of this question and going on mostly blind optimism that he really does want some tips and not a solution:
    1. Use split to seperate the words. You probably want to split on a space and then disregard punctuation somehow, either delete it entirely or remove it and then restore at the end
    2. foreach word in the list you got from split, use substr to find the first letter
    3. You can then append data by using either the contecate operator: . or just double quotes in the form: $variable="${variable}new_data";, but this case is tailor made for using the appending form of the contecate operator
    4. Assemble the list of words back together again, restore punctuation and you have yer sentence.
Re: Pig latin translation
by allolex (Curate) on Oct 29, 2003 at 06:08 UTC
Re: Pig latin translation
by etcshadow (Priest) on Oct 29, 2003 at 05:50 UTC
    I hate to say it, but I caught in the chatterbox that this a homework assignment... I wonder how other monks feel about doing someone's homework for them.

    I'll save the "teach a man to fish" speach, as it's been covered pretty well recently. On top of that, though, is the moral issue of doing someone's homework for them.

    I used to teach beginner-level programming classes (among other things), and the very thought that someone would turn to a site like this, in the middle of the night, to have their homework (probably due at 8:30 tomorrow morning) done for them... well, it just makes me kind of sad. You know, you've probably got a TA somewhere who'd have been more than happy to work through this problem with you, and you'd have certainly learned more.


    ------------
    :Wq
    Not an editor command: Wq
Re: Pig latin translation
by jacques (Priest) on Oct 29, 2003 at 04:59 UTC
    Break your problem down into parts. It is easier to defeat a problem piece by piece. At this point, we don't know if you even know how to run a Perl program.
Re: Pig latin translation
by ehdonhon (Curate) on Oct 30, 2003 at 19:21 UTC
Re: Pig latin translation
by Mr. Muskrat (Canon) on Oct 30, 2003 at 03:38 UTC