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

 

posted @ 2018-04-13 21:12  QIYUEXIN  阅读(272)  评论(0编辑  收藏  举报