http://www.perlmonks.org?node_id=11117663


in reply to Split confusion

If you're processing a list of upper-cased names and want to turn them into "properly" cased names, why not just do that?

c:\@Work\Perl\monks>perl -wMstrict -le "my @names = ( 'JAMES SMITH-JONES', 'BOB SMITH-SMYTHE-SMITH', 'J. JONAH JAMESON', 'BILLY BOB THORNTON', ); ;; for my $name (@names) { printf qq{'$name' -> }; $name =~ s{ \b ([[:upper:]]+) \b }{\u\L$1}xmsg; print qq{'$name'}; } " 'JAMES SMITH-JONES' -> 'James Smith-Jones' 'BOB SMITH-SMYTHE-SMITH' -> 'Bob Smith-Smythe-Smith' 'J. JONAH JAMESON' -> 'J. Jonah Jameson' 'BILLY BOB THORNTON' -> 'Billy Bob Thornton'

Update: See also Falsehoods Programmers Believe About Names.


Give a man a fish:  <%-{-{-{-<