while (<>) { $_ = ucfirst; s/([!.?])(\s+)(\w)/$1$2\U$3/g; print; }