Search code examples
perlemail-address

How can I filter email addresses that belong in a particular domain using Perl?


How can I scan through a file which contains email addresses that are separated by a new line character and get rid of those that belong to a certain domain, e.g. hacker@bad.com. I want to get rid of all email addresses that are @bad.com


Solution

  • Use grep instead of Perl

    grep -v '@bad\.com' inputfile > outputfile
    

    On Windows

    findstr /v "@bad\.com" inputfile > outputfile