my $string = 'this is a string of text'; 
$string =~ s/\b(\w+)\b/ucfirst($1)/ge; 
print "$string\n";