当前位置:首页 » Perl » Perl chop()函数

Perl chop()函数

perl chop()函数,chop()函数学习例子,chop()函数实例代码,chop()函数在线教程等

语法

chomp VARIABLE

chomp( LIST )

chomp


定义和用法

删除的最后一个字符EXPR,LIST的每个元素或没有指定值则为 $_ if 。

返回值

  • 从EXPR中的字符删除

  • 在列表上下文中,从List中的最后一个元素字符删除

例子

#!/usr/bin/perl

$string1 = "This is test";
$retval  = chop( $string1 );

#by www.gitbook.net
print " Choped String is : $string1\n";
print " Character removed : $retval\n";

这将产生以下结果

 Choped String is : This is tes
 Number of characters removed : t