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 casechanged_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 casechanged_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