perl -pne "s/\..+//" old.txt >new.txt
perl -pne 's/(.+)\.(.+)/$1/' old.txt >new.txt
或者
perl -lne 'print((split /\./)[0])' old.txt >new.txt
方法很多。
All roads lead to Rome !
代码如下:#! usr/bin/perl -w
use strict
use warnings
open (FILE,"./a.txt") or die "can't open file:$!"
open (NEWFILE,"./b.txt") or die "can't open file:$!"
while(my $line = <STDIN>)
{
chomp($line)
my $newline = $line =~ s/4/5/g
print NEWFILE $newline
}
close FILE
close NEWFILE
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)