in reply to finding and deleting repeated lines in a file

Is the file too big to slurp into an array? If not...something like the following from the Cookbook should work:
open(FILE,"peptides.txt"); @peptides=<FILE>; %seen=(); @unique=grep{! $seen{$_} ++} @peptides;
Your unique peptides will now be in @unique
-Jason

Replies are listed 'Best First'.
Re: Re: finding and deleting repeated lines in a file
by Becky (Beadle) on Jun 21, 2002 at 15:56 UTC
    Hi, thanks for that - it sort of works, but only seems to find the first repeat. For example if my file looks like: TRHF 0 KJKF 0 DFJE 0 DJFE 0 KSLR 0 SKJR 0 HGDF 0 TRHF 0 KJKF 0 it will remove the second 'TRHF 0' but stop there and leave all the other repeats. Any ideas? I'm quite new to perl so be gentle!
      Where are the newlines? Just out of curiosity...the example you posted above didn't have any...could you post a more accurate input example? Thanks,
      Jason