perl uc,lc,ucfirst,lcfirst的用法
来源:互联网 发布:德国航空发动机知乎 编辑:程序博客网 时间:2024/05/18 02:58
在perl中,我们可以通过uc,lc,\U,\L来修改变量的大小写。其中uc,\U是将变量中的字母全部转换为大写,对应的lc和\L是将变量中的字母全部转换为小写。如果我们只想将变量的首字母大写或将变量的首字母小写,我们可以使用perl提供给我们的另外两个函数ucfirst和lcfirst来实现,下面我们来看一个具体的例子:
#! /usr/bin/perl
use strict;
use warnings;
my $littile = "hello";
print "little:$little\n";
my $big = uc($little);
print "big:$big";
$little = lc($big);
print "little:$little\n";
$big = "\U$little";
print "big:$little";
$little = "\l$big";
print "little:$little\n";
$big = ucfirst($little);
print "big:$little\n";
$little = lcfirst($big);
print "little:$big\n";
上面的这个程序打印的结果如下:
hello
HELLO
hello
HELLo
hello
Hello
hello
当你掌握了上面的的用法之后,你可以做任意的组合,例如ucfirst(lc($big))或者是其他更复杂的使用方法。
- perl uc,lc,ucfirst,lcfirst的用法
- Perl中lc/uc函数
- Perl中uc和lc函数
- PHP 大小写转换函数 lcfirst ucfirst ucwords strtolower strtoupper
- perl:DNA序列翻译成氨基酸序列的若干方法,直接法,简并法,哈希法,以及perl中的uc和lc函数(上)
- php中的几个字符串操作函数strtoupper strtolower ucwords ucfirst lcfirst函数
- ucwords和ucfirst用法举例!!
- perl-数组的用法
- perl-hash的用法
- [perl]defined的用法
- perl的特殊用法
- perl的select用法
- perl-数组的用法
- perl对于encode的用法
- Perl调试器的用法
- perl对于encode的用法
- Perl中grep的用法:
- Perl调试器的用法
- 关于自定义组件被点击或选中时背景的方法
- [分享]SAP概念--集团-公司-公司代码
- v880+ 二十种方法,教您省电!安卓手机
- 哲学家进餐问题与生产者与消费者问题(java实现)
- indexOf()练习,查找某个字符出现的次数
- perl uc,lc,ucfirst,lcfirst的用法
- javascript检测密码弱强
- ie6.0中关于动态改变html中select标签中option的处理方法
- Extjs TextField的maxlength不起作用
- 图解SQL Server 2008安装和配置过程
- jsp之get和set区别与联系!
- SYSTEM.GC FINALIZE小小的注释
- PHP的抽象类、接口的区别和选择
- javasscript ajax请求封装(参考)