Perl中的lcfirst()函數在將第一個字符轉換為小寫字母後返回字符串VAR或$_。
用法: lcfirst(VAR)
參數:
VAR:將第一個字符轉換為小寫的句子
返回:字符串VAR或$_,首字符小寫
範例1:
#!/usr/bin/perl
# Original String containing both
# lower and upper case letters
$orignal_string = "GEEkS FoR geEkS";
# Converting the First character to Lower case
$changed_string = lcfirst($orignal_string);
# Printing the original String
print "Original String : $orignal_string\n";
# Printing the Changed String
print "Changed String : $changed_string\n";
輸出:
Original String : GEEkS FoR geEkS Changed String : gEEkS FoR geEkS
範例2:
#!/usr/bin/perl
# Original String containing
# lower and upper case letters
# as well as numerics
$orignal_string = "G33kS F0R g3EkS";
# Converting the first character to Lower case
$changed_string = lcfirst($orignal_string);
# Printing the original String
print "Original String : $orignal_string\n";
# Printing the Changed String
print "Changed String : $changed_string\n";
輸出:
Original String : G33kS F0R g3EkS Changed String : g33kS F0R g3EkS
相關用法
- Perl sin()用法及代碼示例
- Perl abs()用法及代碼示例
- Perl cos()用法及代碼示例
- Perl oct()用法及代碼示例
- Perl int()用法及代碼示例
- Perl log()用法及代碼示例
- Perl tell()用法及代碼示例
- Perl each()用法及代碼示例
- Perl exp用法及代碼示例
- Perl ord()用法及代碼示例
- Perl chr()用法及代碼示例
- Perl hex用法及代碼示例
- Perl uc()用法及代碼示例
- Perl rename()用法及代碼示例
- Perl wantarray()用法及代碼示例
注:本文由純淨天空篩選整理自Code_Mech大神的英文原創作品 Perl | lcfirst() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。