用来除去最后的换行等空白字符。
例程:
#!/usr/bin/perl #chomp.pl use warnings; use strict; print "Input a string & a number by order! "; my$the_str = <>; my$the_numb=<>; print "Input a string & a number by order! "; 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