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.
ucfirst(string)
As a parameter, the ucfirst()
function requires a string whose first character is to be converted to uppercase.
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$_
.
#stringprint "ucfirst('educative') : ".ucfirst('educative'). "\n";#string with numberprint "ucfirst('educaTive09') : ".ucfirst('educaTive09'). "\n";#string is omittedprint "ucfirst() : ".ucfirst(). "\n";