chomp
Posted QIYUEXIN
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了chomp相关的知识,希望对你有一定的参考价值。
用来除去最后的换行等空白字符。
例程:
#!/usr/bin/perl #chomp.pl use warnings; use strict; print "Input a string & a number by order!\n"; my$the_str = <>; my$the_numb=<>; print "Input a string & a number by order!\n"; chomp(my$str_=<>, my$num_=<>); print "The result is :"; print $the_str," ",$the_numb; print "The result(chomp) is :"; print $str_," ",$num_;
运行结果:
$ perl array.pl Input a string & a number by order! no chomp 123 Input a string & a number by order! has chomp 456 The result is :no chomp 123 The result(chomp) is :has chomp 456
以上是关于chomp的主要内容,如果未能解决你的问题,请参考以下文章
为啥我的文件内容/用户输入不匹配? (缺少chomp规范)[重复]