Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl #checks for valid email address #usage validemail <file containing email addresses> use warnings; use strict; use Mail::CheckUser; use Parallel::ForkManager; use Fcntl qw/:flock :seek/; use FileHandle; my $pm=new Parallel::ForkManager(20); my $addrfile = $ARGV[0] || die "Usage validemail <file containing email addresses> Will return two files: goodmails.csv and badmails.csv. If these files exits already they will be deleted."; my ($is_valid, $host, $x, @mx, $add, @adds); #custom words that make emails invalid to you my @custom = qw/ postmaster webmaster /; my $regex = join "|", @custom; $regex = qr/$regex/; open (EMAILS, "$addrfile"); #remove troublesome windows /r characters #and leading whitespace while (<EMAILS>){ $_ =~ s/\015//; $_ =~ s/^\s*//; chomp $_; push @adds, $_; } close (EMAILS); #warning, I will delete existing files open (BADADDR, ">badmails.csv") || die; open (GOODADDR, ">goodmails.csv") || die; #to prevent strange writing problems #when running threads we must set the #write buffers see #to prevent strange writing problems #when running threads we must set the #write buffers see #http://www.perlmonks.org/index.pl?node_id=348465 autoflush BADADDR 1; autoflush GOODADDR 1; #remove custom regexes $x = 0; while ($x <= $#adds){ if ($adds[$x] =~ m/$regex/){ splice @adds, $x, 1; }else{ $x++; } } #when using Mail::UserCheck set #these variables #timeout on DNS and SMTP network checks $Mail::CheckUser::Timeout = 10; foreach $add (@adds){ $pm->start and next; if (Mail::CheckUser::check_email($add)){ writeaddr(*GOODADDR, $add); #address is good $pm->finish; }else{ writeaddr(*BADADDR, $add); #address is bad $pm->finish; } } $pm->wait_all_children; close (BADADDR); close (GOODADDR); sub writeaddr{ my $FH = $_[0]; my $address = $_[1]; flock $FH, LOCK_EX or die "Flock failed: $!\n"; seek $FH, 0, 2 or die "Seek failed: $!\n"; print $FH "$address\n"; flock $FH, LOCK_UN or die "unFlock failed: $!\n"; }

In reply to Valid Email Filter by neilwatson

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (8)
    As of 2020-02-28 13:22 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      What numbers are you going to focus on primarily in 2020?










      Results (123 votes). Check out past polls.

      Notices?