Perl ucfirst 函式



描述

此函式返回僅將第一個字元大寫的 EXPR 的值。如果省略 EXPR,則使用 $_。

語法

以下是此函式的簡要語法 -

ucfirst EXPR

ucfirst

返回值

此函式返回第一個字元為大寫的字串。

示例

以下示例程式碼展示了其基本用法 -

#!/usr/bin/perl -w

$string = 'the cat sat on the mat.';
$u_string = ucfirst($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.