perl中chomp的使用

来源:互联网 发布:管家婆数据库如何安装 编辑:程序博客网 时间:2024/05/22 06:44

在输入的过程中主义使用chomp才能够得到正确的结果

如下程序:

print "Please input an string and a number by order!\n";$the_string=<>;$the_numb=<>;print "The result is \n";print "$the_string"x"$the_numb";
结果如下:

The result is mymymymymy
这里的问题便是没有使用chomp引起的

如果加入chomp如下:

print "Please input an string and a number by order!\n";chomp($the_string=<>);chomp($the_numb=<>);print "The result is \n";print "$the_string"x"$the_numb";
那么就会得到如下的结果:

The result is mymymymymy





原创粉丝点击