Hi monks, I have a list of identifiers in excludes.txt and a large file which contains the identifier in the first filed of the file (large.txt). I need to print only the lines of large.txt that do not contain an item in excludes.txt in the first field. I have tried the following code but it is not working for reasons unknown to me...
#!/usr/bin/perl -w use strict; open(EXCLUDES,"<",$ARGV[0]) or die("could not open $ARGV[0]!"); my @excludes = <EXCLUDES>; chomp(@excludes); open(LARGE,"<",$ARGV[1]) or die("could not open the $ARGV[1]!"); foreach my $id (@excludes) { while (<LARGE>) { print if !/$id/; } } close(EXCLUDES); close(LARGE);
_LARGE_ 9999853 5615 4 148656321 999986 5615 14 94873609 9999883 5615 4 860669 9999929 5615 4 73689618 9999931 5615 4 31286083 9999944 5615 4 148596445 999995 5615 10 78405504 9999963 5615 4 84291761 9999966 5615 4 5978256 9999979 5615 4 135953341
_EXCLUDES_ 9999853 999986
The large file is tab delimited. Could somebody kindly point out my mistake/s? Additionally, the large file is quite large (~30Gb) so any suggestions for a more efficient way to implement this would be appreciated

In reply to filter a file using an exclusion list by coldy

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.