samsonp81,
I understand what it is like to want to write code that is above my head. While the intent of Re: Refactoring a large script is not applicable to your situation, a lot of the advice inside is. The following is unfinished code that should give you some help as well.
#!/usr/bin/perl use strict; use warnings; use DBI; # Establish connections to your respective databases my $email_dbh; my $email_sth; my $names_dbh; my $names_sth; open(my $fh, '>', 'bad.email') or die "Unable to open 'bad.email' for +writing: $!"; while (my ($email) = $email_sth->fetchrow_array()) { my @names = guess_names($email); if (! @names) { print $fh $email, "NONE FOUND\n"; next; } my $found; for my $name (@names) { my ($gender) = $names_sth->execute($name); if (defined $gender) { print join "\t", $email, $name, $gender; print "\n"; $found = 1; last; } } if (! $found) { print $fh $email, (join ", ", @names), "\n"; } } # After each run, check 'bad.email' to see if you can refine your patt +erns sub guess_names { my ($email) = @_; my @guess; # Strip domain from email address $email =~ s///; # See if it might be first.last, first_last, first-last if ($email =~ //) { push @guess, $1, $2; } # See if it might be first name followed by last initial push @guess, substr($email, 0, length($email) - 1); # Add more patterns here return @guess; }

Cheers - L~R


In reply to Re^2: Gender Prediction by Limbic~Region
in thread Gender prediction by samsonp81

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, details, 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, summary, 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.