If I'm understanding your issue, you have two data sets. One contained in removelist.txt:
user1@example.com user3@example.com ...
The other in masterlist.txt:
user1@example.com user2@example.com user3@example.com USER1@EXAMPLE.COM<mailto:USER1@EXAMPLE.COM> user4@example.com user5@example.com user5@example.com<mailto:user5@example.com> ...
You want items from the first set to be removed from the second. Excellent suggestions have been offered, and this is a "classic issue."
See if the following will work for your situation:
use Modern::Perl; use File::Slurp qw/ read_file write_file /; my $removeList = join '|', map { chomp; $_ } read_file 'removelist.txt'; write_file 'finallist.txt', grep !/$removeList/i, read_file 'masterlist.txt';
With the above two data sets, here is the output to finallist.txt:
user2@example.com user4@example.com user5@example.com user5@example.com<mailto:user5@example.com>
The script only does what you mentioned, viz., joins the removelist.txt items with the pipe character (alternation operator) for a !"or" regex of email addresses used by grep on the masterlist.txt lines.
Hope this helps!
In reply to Re: Removing users from a list
by Kenosis
in thread Removing users from a list
by gossamer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |