$s ='the quick brown fox'; $s =~ s/\b(\w+)\b/ucfirst $1/ge; print $s; #### The Quick Brown Fox