Perl uc 函式



描述

此函式返回 EXPR 的大寫版本,如果未指定,則返回 $。檢查 ucfirst() 函式,該函式只返回首字母大寫的字串。

語法

以下是此函式的簡單語法:-

uc EXPR

uc

返回值

此函式返回大寫的字串。

示例

以下是顯示其基本用法的示例程式碼:-

#!/usr/bin/perl -w

$string = 'the cat sat on the mat.';
$u_string = uc($string);

print "First String |$string|\n";
print "Second String |$u_string|\n";

當執行上述程式碼時,將生成以下結果:-

First String |the cat sat on the mat.|
Second String |THE CAT SAT ON THE MAT.|
perl_function_references.htm
廣告
© . All rights reserved.