当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。