加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl中chomp的使用

发布时间:2020-12-15 21:05:51 所属栏目:大数据 来源:网络整理
导读:在输入的过程中主义使用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才能够得到正确的结果

如下程序:

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 
my
my
my
my
my
这里的问题便是没有使用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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读