试了一下,得到下面的信息:

[li...@localhost try]$ more lll
lllll
lllll
skdfksdfas
lllll
skdfksdfas
kkkk
[li...@localhost try]$ perl -nle "print unless $a{$_}++;" lll > ll
Can't modify anonymous hash ({}) in postincrement (++) at -e line 1, near 
"}++"
Execution of -e aborted due to compilation errors.



----- Original Message ----- 
From: "Tiger Peng" <[email protected]>
To: <[email protected]>
Sent: Wednesday, November 11, 2009 11:20 PM
Subject: [PerlChina] Re: 请教哈:将文件中重复的行,替换,只保留一行


> 试试:
> perl -nle 'print unless $a{$_}++' infile > outfile.
> 如果文件太大,要用很多memory。
>
> 2009/11/11 Haiyan Lin <[email protected]>:
>>
>> 希望保留原顺利,对于重复行,只保留首次出席的那行
>>
>>
>> ----- Original Message -----
>> From: "TBY" <[email protected]>
>> To: "PerlChina Mongers 讨论组" <[email protected]>
>> Sent: Wednesday, November 11, 2009 7:36 PM
>> Subject: [PerlChina] Re: 请教哈:将文件中重复的行,替换,只保留一行
>>
>>
>>> 用hash有问题的吧,行顺序全打乱了要紧么?
>>>
>>> 用uniq是最好的。
>>> >
>>>
>>
>>
>> >
>>
>
> >
> 


--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛“PerlChina Mongers 讨论组”论坛。
 要在此论坛发帖,请发电子邮件到 [email protected]
 要退订此论坛,请发邮件至 [email protected]
 更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---

回复