A regex is best suited to altering the array in place s/(\w)(\w*)/\U$1\E$2/ for @array; You can use a regex, but to make a new array with initial caps, ucfirst is handier, my @arrayl = map {ucfirst} @array; The regex can also be applied to a string with the /g flag
$_ = 'foo bar foobar barfoo 1 2 3'; s/(\w)(\w*)/\U$1\E$2/g; print; # Foo Bar Foobar Barfoo 1 2 3
After Compline,
Zaxo
In reply to Re: Capitalize the 1st letter of each word
by Zaxo
in thread Capitalize the 1st letter of each word
by TASdvlper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |