Return an uppercased version of a string.
The uc function returns a copy of the string with all characters converted to uppercase. It does not modify the original string. If called without an argument, it operates on $_.
uc respects the current locale if the use locale pragma is in effect. It also handles Unicode characters correctly, converting them according to Unicode case-folding rules.
For uppercasing just the first character of a string, use ucfirst instead. The lc function performs the opposite operation, converting to lowercase.
| Name | Description | Optional |
|---|---|---|
EXPR |
The string to convert to uppercase. Defaults to $_ if omitted. | Yes |
my $str = 'hello world';
print uc($str); # HELLO WORLD
print uc('perl'); # PERL