|
|
|
|
 请问如何去掉文本中重复的内容? - sharkman [ 2005-04-19 01:38 | 1,100 byte(s)]
 Re: 请问如何去掉文本中重复的内容? - horsley [ 2005-08-21 19:56 | 98 byte(s)]
 Re: 请问如何去掉文本中重复的内容? - yulongcn [ 2007-12-10 17:15 | 8 byte(s)]
 Re: 请问如何去掉文本中重复的内容? - sharkman [ 2005-04-19 17:53 | 698 byte(s)]
 Re: 请问如何去掉文本中重复的内容? - wandys [ 2005-04-19 21:18 | 175 byte(s)]
 Re: 请问如何去掉文本中重复的内容? - sharkman [ 2005-04-19 22:03 | 22 byte(s)]
 Re: 请问如何去掉文本中重复的内容? - sharkman [ 2005-04-20 00:57 | 17 byte(s)]
 Re: 请问如何去掉文本中重复的内容? - sharkman [ 2005-04-19 16:33 | 99 byte(s)]
|
|
|
|
[Original]
[Print]
[Top]
|
就是这么个事情:
一个txt吧,里面一行一行的,有重复的行,想把重复的变成一个,应该怎么写?
my $readfile = "readfile.txt";
my $writefile = "writefile.txt";
print "请输入本次要处理的行数:";
my $b = <STDIN>;
chomp $b;
if (open (readfile,"$readfile") || die ("can not open readfile")){
@line = <readfile>;
}
for (my $a = 0 ; $a <= $b-1 ; $a++ ){
my $e = $a+1;
print "共要处理$b个,且第$e个正在进行
";
if (open (writefile,">>$writefile") || die ("can not open writefile")){
怎么写?
print writefile 怎么写?;
}
}
|
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
这么写确实去掉了几行,但是还是不对啊
my $readfile = "readfile.txt";
my $writefile = "writefile.txt";
if (open (readfile,"$readfile") || die ("can not open readfile")){
@line = <readfile>;
}
%lines = @line;
if (open (writefile,">>$writefile") || die ("can not open writefile")){
@this = %lines;
print writefile ("@this");
}
|
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
my %line;
while (<>) {
next if exists $line{$_};
$line{$_} = 1;
print;
}
|
|
|
----
UN*X is user^H^H^H^Hfriend-friendly.
|
|
[Original]
[Print]
[Top]
|
|
|