FWIW, the following may give a slight improvement in speed, simplicity or generality (I will not bother to put it into file-processing form):
>perl -wMstrict -le
"for (@ARGV) {
s{ (?<= [[:upper:]]) ([[:upper:]]+) }{\L$1}xmsg;
print;
}
"
"XYZZY" "RUN4LIFE" "RUN42LIFE CO"
"GENERAL WIDGET CO., INTL" "MI-GO BRAIN CYLINDERS, IPTY."
Xyzzy
Run4Life
Run42Life Co
General Widget Co., Intl
Mi-Go Brain Cylinders, Ipty.
Supposed advantages:
-
The ([[:upper:]]+) quantified capture grabs as much as possible of whatever is to be lower-cased (rather than capturing a character at a time);
- The use of the \L interpolation modifier eliminates the need for evaluation in the regex (i.e., no //e regex modifier);
-
The use of [[:upper:]] and \L bring locale fully into play (I think).