Hello, I am a novice at Perl.

I have a SOURCE text file with a list of strings, such as

http://www.google.com
www3.manish.net
www.nov8rix.com
www.thisisannoying.com

and a 2nd text file FILTER TERMS with a list of terms such as

google
manish
www.thisisannoying.com

What I want to do is read the 2nd file and using the list of those terms, to filter out the first file.

The desired end result OUTPUT would be

www.nov8rix.com

It would not write

http://www.google.com --- because it matches the "google"
www3.manish.net --- because it matches the "manish"
www.thisisannoying.com --- because it matches the "www.thisisannoying.com"

Can anyone please help me figure out how to do this?

Here is the code I have thus far (this is the 20th iteration of various attempts, having spent about 5 hours on this already today --- see, I am new at this!)
#!/usr/bin/perl open (F1, "<filterTerms.txt"); open (F2, "<source.txt"); my %terms = (); my %source = (); while (<F1>) { my $term=$_; chomp ($term); $terms{$term}=$term; } while (<F2>) { my $item=$_; chomp ($item); $source{$item}=$item; foreach (keys %source) { if ($source=~m/($term{$term})/) { #do nothing } else { print $1."\n"; } } } close (F1); close (F2);
Thank you.

In reply to Filtering Source Text File with 2nd Text File of Terms by Loops303

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.