珀尔 | lc() 小写转换函数
Perl 中的 lc()函数返回 VAR 的小写版本,如果省略 VAR,则返回 $_。
Syntax: lc(VAR)
Parameter:
VAR: Sentence which is to be converted to lower case
Return:
Lowercased version of VAR, or $_ if VAR is omitted
示例 1:
Perl
#!/usr/bin/perl
# Original String containing both
# lower and upper case letters
$original_string = "GEEkS FoR geEkS";
# Converting the string to Lower case
$changed_string = lc($original_string);
# Printing the original String
print "Original String : $original_string\n";
# Printing the Changed String
print "Changed String : $changed_string\n";
Perl
#!/usr/bin/perl
# Original String containing
# lower and upper case letters
# as well as numerics
$original_string = "G33kS F0R g3EkS";
# Converting the string to Lower case
$changed_string = lc($original_string);
# Printing the original String
print "Original String : $original_string\n";
# Printing the Changed String
print "Changed String : $changed_string\n";
输出:
Original String : GEEkS FoR geEkS
Changed String : geeks for geeks
示例 2:
Perl
#!/usr/bin/perl
# Original String containing
# lower and upper case letters
# as well as numerics
$original_string = "G33kS F0R g3EkS";
# Converting the string to Lower case
$changed_string = lc($original_string);
# Printing the original String
print "Original String : $original_string\n";
# Printing the Changed String
print "Changed String : $changed_string\n";
输出:
Original String : G33kS F0R g3EkS
Changed String : g33ks f0r g3eks