in reply to making first letter of all words in array upper case
Addressing your second issue first, you probably should use a regular expression rather than index to do it. The index() function will return the position of the first occurrence of the string you are searching for. In your case, this means that unless the first occurrence of an exclamation point, question mark, or period is the last character in the string it will break. I think you can see how that matches your observations. A quick fix would be to use rindex() which searches from the end of the string backward but, as I said, a regex would be better. Something like:
$string .= '.' if $string !~ /[.!?]$/;
Regarding your first issue, look at the ucfirst() function. After you put the names in the array, you could do it like this:
@array = map ucfirst, @array;
-sauoq "My two cents aren't worth a dime.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: making first letter of all words in array upper case
by tachyon (Chancellor) on Dec 31, 2002 at 22:00 UTC |