Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

perl
string
uppercase
communitycreator

What is the string.ucfirst() function in Perl?

Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The ucfirst() function in Perl converts the first character of a string to uppercase.

The following figure shows a visual representation of the ucfirst() function.

Figure 1: Visual representation of ucfirst() function

Syntax


ucfirst(string)

Parameter

As a parameter, the ucfirst() function requires a string whose first character is to be converted to uppercase.

Return value

The ucfirst() function converts the first character of a string to uppercase.


The rest of the string i.e. other than the first character, stays the same.


If the string parameter is omitted, then it returns $_.

Code

#string
print "ucfirst('educative') : ".ucfirst('educative'). "\n";
#string with number
print "ucfirst('educaTive09') : ".ucfirst('educaTive09'). "\n";
#string is omitted
print "ucfirst() : ".ucfirst(). "\n";

RELATED TAGS

perl
string
uppercase
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring