PPS:学习Perl语言编程中……,打算边学边把Perl函数整理出来。
介绍:
chomp函数通常会删除变量里包含的字符串尾部的换行符。它是chop函数的一个略微安全些的版本,因为它对没有换行符的字符串没有影响。更准确地说,它根据了解$/的当前值删除字符串终止符,而不只是最后一个字符。
和chop不同,chomp返回删除的字符数量。你不能chomp一个直接量,只能处理变量。
用法:
chomp VARIABLE chomp LIST chomp
例子:
#!/usr/bin/perl
$string1 = "This is test";
$retval = chomp( $string1 );
print " Choped String is : $string1\n";
print " Number of characters removed : $retval\n";
$string1 = "This is test\n";
$retval = chomp( $string1 );
print " Choped String is : $string1\n";
print " Number of characters removed : $retval\n";
结果如下:
Choped String is : This is test Number of characters removed : 0 Choped String is : This is test Number of characters removed : 1
chomp函数 完~
有点相关的文章
- PHP 正则表达式 (0.500)
- php将HTML转换为txt文本的函数 (0.500)
- PHP 截取字符串专题 (0.500)
- PHP 计算页面执行时间 (0.500)
- 去掉特定长度的短序列&取motif上下游一定长度的序列 (0.500)
- Cygwin在Windows上提供一个完整的UNIX shell (RANDOM - 0.500)







/呲牙
[回复]
Perl有所耳闻~~仅此~呵呵
[回复]
不用学更好嘛.. 偶是工作需要嘛~~
[回复]
读取外部文件时的必备函数~
[回复]