I have a text file containing a list of names that I need to change to the heading (words should start with a capital letter, with the exception of most articles, conjunctions and prepositions).
For example, this list of book titles:
barbarians at the gate hot, flat, and crowded A DAY LATE AND A DOLLAR SHORT THE HITCHHIKER GUIDE TO THE GALAXY
should be changed to:
barbarians at the gate hot, flat, and crowded A DAY LATE AND A DOLLAR SHORT THE HITCHHIKER GUIDE TO THE GALAXY
I wrote the following code:
while(<DATA>) { $_=~s/(\s+)([az])/$1.uc($2)/eg; print $_; }
But he smoothes the first letter of each word, even words such as "at", "the" and "a" in the middle of the name:
barbarians at the gate hot, flat, and crowded A DAY LATE AND A DOLLAR SHORT THE HITCHHIKER GUIDE TO THE GALAXY
How can i do this?
source share