while (<>) {
/^#/ and next; # skip comments
- my ($iso, $name, $cont) = (split /\t/)[0, 4, 8];
- my $class = "c-\L$cont";
- $cc{ lc $iso } = [ $name, $class ];
+ my ($iso, $name, $cont, $tld) = (split /\t/)[0, 4, 8, 9];
+ my @info = ($name, "c-\L$cont");
+ $info[3] = $tld if $tld =~ s/\A\.// and $tld ne lc $iso;
+ $cc{ lc $iso } = \@info;
}
$cc{io}->[2] = "Chagos Islands";
$cc{um}->[2] = "U.S. isl.";
for (values %cc) {
- for ($_->[2] //= $_->[0]) {
+ my $abbr = do {
+ local $_ = $_->[2] // $_->[0];
s/,.*//;
s/(?<=.)\(.*\)\s*//;
s/ republic\b//gi;
s/New /n./g;
s/(\S)(\S+)-/$1-/g; # strip most chars preceding dash
s/(\S{4}[b-df-hj-np-tv-xz])((?<!Austr)(?!land)\w{2,})/$1./g; # abbreviate (at consonant)
- }
+ $_;
+ };
+ $_->[2] = $abbr if $abbr ne $_->[0]; # short name if different
}
say "# automatically generated by $0";