Lingua::EN::NameParse and Text::Names can be of help here.
use Lingua::EN::NameParse qw(clean case_surname);
use Text::Names;
use strict;
use warnings;
# optional configuration arguments
my %args =
(
auto_clean => 1,
lc_prefix => 1,
initials => 3,
allow_reversed => 1,
joint_names => 0,
extended_titles => 0
);
my $parser = Lingua::EN::NameParse->new(%args);
my $error;
for my $input (
'JAMES SMITH-JONES',
'BOB SMITH-SMYTHE-SMITH',
'J. JONAH JAMESON',
'BILLY BOB THORNTON'
){
print "\n\ninput name is '$input'\n";
$error = $parser->parse($input);
die "error: $error" if $error;
print $parser->report;
my $name3 = Text::Names::cleanName($input);
print "name3: $name3\n";
}
btw if you are inserting names into DB :) xkcd#327
bw, bliako