Perl lc()函数用于小写转换

Perl lc()函数用于小写转换

Perl中的lc()函数返回VAR的小写版本,如果省略了VAR,则返回$_。

语法: lc(VAR)

参数:

VAR: 要转换为小写的句子

返回:

VAR的小写版本,如果省略VAR,则为$_

例1:

#!/usr/bin/perl
 
# Original String containing both
# lower and upper case letters
original_string = "GEEkS FoR geEkS";
 
# Converting the string to Lower casechanged_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:

#!/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 casechanged_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

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程