The second example gives you an array filled with all the words in the sentence, in order. Now, if your question is how to put all the words into individually named scalar variables the answer is you can't. I mean, logically, how can you put n number of words into n number of scalars when n is unknown? You can't. That's why God invented the array, so you don't have to know. @words will be exactly as long as the number of words in your sentence, and you can get to each one whenver you wish, and have your nasty little way with them.# Yes, I know how many "words" there are. ($word_one, $word_two, $word_three) = split " ", $sentence; # No, I don't know how many words there are. @words = split " ", $sentence;
Gary Blackburn
Trained Killer
In reply to Re: How can I place each "word" of a string in a varible if I don't know the length of the string?
by Trimbach
in thread How can I place each "word" of a string in a varible if I don't know the length of the string?
by anon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |