#!usr/bin/perl use strict; use warnings; my $string1 = "lets see. This is a test"; capitalize( $string1 ); sub capitalize { my $string = shift(); print "$string\n"; $string =~ s/(([.!?]|\A)\s*)([a-z])/$1\u$3/g; print "$string\n"; }