What is the uc() function in Perl?

The uc() function in Perl converts a string to uppercase.

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

Visual representation of uc() function

Syntax

uc(string)

Parameter

The uc() function requires only one parameter: a string that is to be converted to uppercase.

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

Return value

The uc() function returns a string that is converted to uppercase.

Code

The following code illustrates how to use uc() function in Perl.

#String
print "uc('educative') : ".uc('educative'). "\n";
#String with number
print "uc('educative09') : ".uc('educative09'). "\n";
#String is omitted
print "uc() : ".uc(). "\n";

Free Resources