@a = ("THIS IS TESTING", "JOE MARCONES", "RESIDENTIAL MAINTENANCE COMPANY", ); s#(.)(\w+)( )?#\U\1\L\2\3#gsi for @a; print join "\n", @a;