I have written a module to do this type of things (and many others, such as comparing files in a very detailed way) on arbitrary large sorted files. It has a detailed documentation and I have been using it happily at my job for the last few months, but I still am not sure on how to provide an adequate test suite for different OS's to upload it to the CPAN (basically, I do not figure out how to provide test samples adequate for different end-of-line characters across various OS's). I can provide the module to you if you wish to try it.

Anyway, the following is an extremely simplified command-line version of the algorithm used by this module for removing duplicates from a file (whatever the definition of duplicate is for your particular problem):

$ cat test.txt AB000000026JHAHKDFK AB000000028JHKHKHKJ AB00000003033AFSFAS AB000000030HJHKH80J AB000000030LOIKJUJ8 AB0000000324446KJHK $ $ perl -ne '$c = substr ($_, 9, 2); print if $c ne $prev_c; $prev_c=$c +;' test.txt AB000000026JHAHKDFK AB000000028JHKHKHKJ AB00000003033AFSFAS AB0000000324446KJHK

In reply to Re: Removing duplicates lines by Laurent_R
in thread Removing duplicates lines by vihar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.