in reply to Re: Gender Prediction
in thread Gender prediction

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