You could do it with tr like so substr($word, 0, 1) =~ tr/a-z/A-Z/; # first char only substr($word, 0, 5) =~ tr/a-z/A-Z/; # first five chars or with sed substr($word, 0, 1) =~ s/(.*)/\U$1/; # first char only substr($word, 0, 5) =~ s/(.*)/\U$1/; # first five chars $word =~ s/(.)/\U$1/; # first char $word =~ s/(.{5})/\U$1/; # first five chars or $word = "\u$word"; # first char perl -pe 's/./\u$&/'