Hi Monks,
I'm after a bit of advice/suggestions on how to best achieve the following:
I have a list of names + initials that I pull from a database and want to check to see if there could be similar names in the db...
smith j could match smith jn
mayer-handel c could match mayer handel c
jones t jnr could match jones t
etc...
I can only think of two methods for doing this:
1. do a select using mysql - my problem here is i dont know how to do such a complex select (or even if it could be done)
2. select all names, store them in a hash and then foreach author scroll through the hash running a "match sub" on each name to see if it matches
# Do some matching
foreach my $auth_id (keys %authors) {
foreach my $mid (keys %authors) {
print "$authors{$auth_id}{'author'} \t matches \t $authors{$mi
+d}{'author'}\n" if ( &matchme( $authors{ $auth_id}, $authors{$mid} )
+);
} # end-foreach
} # end-foreach
sub matchme {
# return true for a match otherwise false.
} # end-sub
2 doesnt seem like the most efficient way of doing things, (10 000 records = 100 000 loops) so I was after any other ideas about the path to take?
Any help would be appreciated.
Cheers,
Reagen
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.