當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Perl lcfirst()用法及代碼示例


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


相關用法


注:本文由純淨天空篩選整理自Code_Mech大神的英文原創作品 Perl | lcfirst() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。