Browse - Programming Tips - How do I convert a string to title case with Perl?
Q. How do I convert a string to title case with Perl?
A. Title Case Is Where Each Word Begins With An Uppercase Letter.
Use this replacement:
$title =~ s/(\w+)/\u\L$1/g;
For each word (\w+) use the \u\L command.
This is exactly the kind of thing that Perl was made for!
Some related functions:
$title = uc($title); # To UPPERCASE
$title = lc($title); # To lowercase
$title = ucfirst($title) # First letter to Uppercase
$title = lcfirst($title) # First letter to lowercase