Sunday, February 25, 2007

Remove the common elements of two sets

I use this to see who from the first list has replied to my email. The script gives me a list of people to remail:


open(FILE, "addresses.txt") or die("Unable to open file");
@list = ;
close(FILE);

open(FILE, "replies.txt") or die("Unable to open file");
@stoplist = ;
close(FILE);


%temp = ();
@temp{@list} = ();
foreach (@stoplist) {
delete $temp{$_};
}
@list = sort keys %temp;


open(FILE, ">noreplies.txt") or die("Unable to open file");
print FILE @list;
close(FILE);