| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
|
2
|
1
|
|
|
1
|
|
5750
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
44
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
105
|
|
|
4
|
1
|
|
|
1
|
|
619
|
use utf8; |
|
|
1
|
|
|
|
|
343
|
|
|
|
1
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1019
|
use Getopt::Long qw(GetOptions); |
|
|
1
|
|
|
|
|
19730
|
|
|
|
1
|
|
|
|
|
7
|
|
|
7
|
1
|
|
|
1
|
|
928
|
use Text::Names::Canonicalize qw(canonicalize_name canonicalize_name_struct); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
137
|
|
|
8
|
1
|
|
|
1
|
|
10
|
use Text::Names::Canonicalize::Rules; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
1842
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
|
|
208181
|
my $locale = 'en_GB'; |
|
11
|
1
|
|
|
|
|
3
|
my $explain = 0; |
|
12
|
1
|
|
|
|
|
3
|
my $show_rules = 0; |
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
50
|
|
|
|
8
|
GetOptions( |
|
15
|
|
|
|
|
|
|
'locale=s' => \$locale, |
|
16
|
|
|
|
|
|
|
'explain' => \$explain, |
|
17
|
|
|
|
|
|
|
'rules' => \$show_rules, |
|
18
|
|
|
|
|
|
|
) or die "Error parsing options\n"; |
|
19
|
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
1061
|
my $name = join ' ', @ARGV; |
|
21
|
1
|
50
|
|
|
|
4
|
if (!length $name) { |
|
22
|
0
|
|
|
|
|
0
|
die <<"USAGE"; |
|
23
|
|
|
|
|
|
|
Usage: |
|
24
|
|
|
|
|
|
|
text-names-canonicalize [options] "Full Name" |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Options: |
|
27
|
|
|
|
|
|
|
--locale LOCALE Locale to use (default: en_GB) |
|
28
|
|
|
|
|
|
|
--explain Show detailed breakdown |
|
29
|
|
|
|
|
|
|
--rules Show resolved ruleset for this locale |
|
30
|
|
|
|
|
|
|
USAGE |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Show resolved ruleset |
|
34
|
1
|
50
|
|
|
|
4
|
if ($show_rules) { |
|
35
|
0
|
|
|
|
|
0
|
my $rules = Text::Names::Canonicalize::Rules->get($locale); |
|
36
|
0
|
|
|
|
|
0
|
require YAML::XS; |
|
37
|
0
|
|
|
|
|
0
|
print YAML::XS::Dump($rules); |
|
38
|
0
|
|
|
|
|
0
|
exit 0; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Canonicalize |
|
42
|
1
|
|
|
|
|
24
|
my $struct = canonicalize_name_struct($name, locale => $locale); |
|
43
|
|
|
|
|
|
|
|
|
44
|
1
|
50
|
|
|
|
4
|
if ($explain) { |
|
45
|
0
|
|
|
|
|
0
|
require YAML::XS; |
|
46
|
0
|
|
|
|
|
0
|
print YAML::XS::Dump($struct); |
|
47
|
0
|
|
|
|
|
0
|
exit 0; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Default: print canonical form |
|
51
|
1
|
|
|
|
|
10
|
print canonicalize_name($name, locale => $locale), "\n"; |