珀尔 | lcfirst()函数
Perl 中的 lcfirst()函数在将第一个字符转换为小写后返回字符串VAR 或 $_。
Syntax: lcfirst(VAR)
Parameter:
VAR: Sentence whose first character is to be converted to lower case
Returns: the string VAR or $_ with the first character lowercased
示例 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