$_ = 'This is the word.'; $_ =~ s[(^\w+)(\s.*\s)(\w+)([[:punct:]]?)$][\u$3$2\l$1$4]; print