Your main problem is when you check to see if the source matches any of the terms, you're only checking the last term in the file.
You're also trying to print a match with the $1 but that's not really what you want.
Beyond that, is there a particular reason you're choosing to use hashes instead of arrays? I would think arrays are more what you want.
# Building the array of terms: my @terms = (); while (my $term = <F1>) { chomp $term; push @terms, $term; }
This way, when you are checking each term against the source, you just need to do this:
# Printing sources that do not match of of the terms: while (my $source = <F2>) { chomp $source; print "$source\n" unless grep { $source =~ /$_/ } @terms; }
In reply to Re: Filtering Source Text File with 2nd Text File of Terms
by Riales
in thread Filtering Source Text File with 2nd Text File of Terms
by Loops303
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |