用来除去最后的换行等空白字符。

例程:

#!/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 Input a string & a number by order!
has chomp The result is :no chomp The result(chomp) is :has chomp
05-23 03:14