首页 > IT职业 > IT生活 > 去掉两个字人名中间的空格
while(<>){
@name=split (" ",$_);
open FH,">>name_file.txt";
my $i=0;
while ($i <=$#name){
$length=length($name[$i])/2;
if ($length>1) {
print FH "$name[$i] ";
}
elsif($length=1){
print FH "$name[$i]$name[$i+1] " ;
$i+=1;
}
$i+=1;
}
print FH "n";
}
close FH;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/6456/viewspace-1015292/ ,如需转载,请注明出处,否则将追究法律责任。