my $d=ucfirst("sample. data some! will be. captilized"); $d=$s/([\!\.]\s*)(\w)/$1\U$2\U/g;