my $string = "word1 word2 word3"; $string = join ' ', map { ucfirst } split /\s+/, $string;