in reply to Searching for best match
Wow, looks like perl is too clever for its own good. You feed it the string "Reuel T" and it magically translates it to "R Tolkien". Now that's DWIM taken too far!
Beside that inconsistency between your input and the output you say you have, your exemple does not illustrate well what you meant by "best match", because in all cases the search string is fully contained in one of the sources. ("John Ronald Reuel T" and "<John Ronald Reuel T>olkien"). If your original search string was indeed "John Ronald R Tolkien", I suppose you'd still want to match "John Ronald Reuel Tolkien"?
And FYI, you can do all this:
in one line (see "matching in list context" in Quote and Quote like Operators): my ($twonames, $others) = /^(\w+ \w+)(?: (.+))?/;#gets first two names (my $twonames=$s)=~s/^(\w+ \w+).*$/$1/; #gets all other names, if they exist (my $others=$s)=~s/^(\w+ \w+)//; #deletes initial space (my $alternativesearch=$others)=~s/^\s//;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Searching for best match
by Sosi (Sexton) on Oct 06, 2014 at 12:54 UTC |