$ perl -pe 's/([A-Z]+)/ucfirst(lc $1)/egi' "THIS IS TESTING" "This Is Testing" "JOE MARCONES" "Joe Marcones" "RESIDENTIAL MAINTENANCE COMPANY" "Residential Maintenance Company" THIS iS a Text IN TITLE CASE This Is A Text In Title Case This isn't right This Isn'T Right And I'm wrong too And I'M Wrong Too e-mail is nice when capped correctly E-Mail Is Nice When Capped Correctly &c &C "Bit o' Mint" "Mano y Mano" "Chris diBona" "Scrooge McDuck" "Bit O' Mint" "Mano Y Mano" "Chris Dibona" "Scrooge Mcduck" "Cruella de Ville" "Jake O'Shaunessy" "Tales from the Crypt" "Cruella De Ville" "Jake O'Shaunessy" "Tales From The Crypt" "Sanford and Son Salvage Company" "Sanford And Son Salvage Company"