珀尔 | uc()函数
Perl 中的 uc()函数在将其转换为大写后返回传递给它的字符串。它类似于 ucfirst()函数,它只返回大写的第一个字符。
注意:已经大写的字符不会被修改。
Syntax: uc String
Returns: string in uppercase.
示例 1:
#!/usr/bin/perl -w
# String to be converted to UPPERCASE
$string = "geeksfOrGeeks";
print "Original String: $string\n";
# Converting the string to
# UPPERCASE using uc() function
$UPPER_STRING = uc($string);
print "Modified String: $UPPER_STRING";
输出:
Original String: geeksfOrGeeks
Modified String: GEEKSFORGEEKS
示例 2:
#!/usr/bin/perl -w
# String to be converted to UPPERCASE
$string = "WelComEToGeeKS";
print "Original String: $string\n";
# Converting the string to
# UPPERCASE using uc() function
$UPPER_STRING = uc($string);
print "Modified String: $UPPER_STRING";
输出:
Original String: WelComEToGeeKS
Modified String: WELCOMETOGEEKS