Perl去除文件的重复行

Perl去除文件重复行的脚本输入文件
在这里插入图片描述
Perl去除文件重复行的脚本
#!/usr/bin/perl
use warnings;
use strict;
my %hash;
my $source_file = “read.log”; #读取文件
my KaTeX parse error: Expected 'EOF', got '#' at position 27: … "write.txt"; #̲写入文件 open (FILE…source_file") or die “Cannot open file KaTeX parse error: Undefined control sequence: \n at position 2: !\̲n̲"; open (SORTED…dest_file”) or die “Cannot open file $!\n”;
while(defined (my KaTeX parse error: Expected '}', got '#' at position 27: …E>)) { #̲从文件中取出要去重的数据 …line); #去除空格
#$line=~ s/[\r\n]+//mg;#取出换行符
KaTeX parse error: Expected '}', got 'EOF' at end of input: hash{ line} += 1;
}
foreach my k ( k e y s p r i n t S O R T E D " k (keys %hash) { print SORTED " k(keysprintSORTED"k\tKaTeX parse error: Expected '}', got 'EOF' at end of input: hash{ k}\n"; #改行打印出列和该列出现的次数到目标文件
}
close (FILE);
close (SORTED);
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
CSDN:Perl脚本常用操作

猜你喜欢

转载自blog.csdn.net/m0_38127487/article/details/114056738