5 my %cc; # map of country code to info array
7 # exceptional reservations
8 ac => ["Ascension Island", "c-oc Xr", undef, 'sh'],
9 cp => ["Clipperton Island", "c-na Xr"],
10 dg => ["Diego Garcia", "c-as Xr", undef, 'io'],
11 ea => ["Ceuta and Melilla", "c-af Xr"],
12 eu => ["European Union", "c-eu Xr"],
13 fx => ["Metropolitan France", "c-eu Xr", undef, 'fr'],
14 ic => ["Canary Islands", "c-af Xr"],
15 su => ["former USSR", "c-eu Xr"],
16 ta => ["Tristan da Cunha", "c-oc Xr", undef, 'sh'],
17 uk => ["(United Kingdom)", "c-eu Xr", undef, 'gb'],
19 # indeterminate reservations
20 dy => ["(Benin)", "c-af Xr", undef, 'bj'],
21 ew => ["(Estonia)", "c-eu Xr", undef, 'ee'],
22 fl => ["(Liechtenstein)", "c-eu Xr", undef, 'li'],
23 ja => ["(Jamaica)", "c-na Xr", undef, 'jm'],
24 lf => ["Libya Fezzan", "c-af Xr", "Fezzan", 'ly'],
25 pi => ["(Philippines)", "c-as Xr", undef, 'ph'],
26 ra => ["(Argentina)", "c-sa Xr", undef, 'ar'],
27 rb => ["Bolivia/Botswana", "c-xx Xr"],
28 rc => ["(RoC)", "c-as Xr", undef, 'tw'],
29 rh => ["(Haiti)", "c-na Xr",undef, 'ht'],
30 ri => ["(Indonesia)", "c-as Xr", undef, 'id'],
31 rl => ["(Lebanon)", "c-as Xr", undef, 'lb'],
32 rm => ["(Madagascar)", "c-af Xr", undef, 'mg'],
33 rn => ["(Niger)", "c-af Xr",undef, 'ne'],
34 rp => ["(Philippines)", "c-as Xr", undef, 'ph'],
35 wg => ["(Grenada)", "c-na Xr", undef, 'gd'],
36 wl => ["(Saint Lucia)", "c-na Xr", "(Saint Luc.)", 'lc'],
37 wv => ["(Saint Vincent)", "c-na Xr", "(Saint Vin.)", 'vc'],
38 yv => ["(Venezuela)", "c-sa Xr", undef, 've'],
42 /^#/ and next; # skip comments
43 my ($iso, $name, $cont) = (split /\t/)[0, 4, 8];
44 $cont =~ s/\AAN\z/aa/; # different antarctica abbreviation
45 my $class = "c-\L$cont";
46 $cc{ lc $iso } = [ $name, $class ];
49 $cc{io}->[2] = "Chagos Islands";
50 $cc{um}->[2] = "U.S. isl.";
53 for ($_->[2] //= $_->[0]) {
59 s/ and / & /g and s/(?<=.)[a-z ]+//g;
61 s/South(?:ern)? /S-/g;
62 s/North(?:ern)? /N-/g;
64 s/(\S)(\S+)-/$1-/g; # strip most chars preceding dash
65 s/(\S{4}[b-df-hj-np-tv-xz])((?<!Austr)(?!land)\w{2,})/$1./g; # abbreviate (at consonant)
69 say "# automatically generated by $0";
71 $Data::Dump::INDENT = '';
78 mkcountries-geonames - Create Perl include of country info from GeoNames data
82 curl http://download.geonames.org/export/dump/countryInfo.txt |
83 tools/mkcountryinfo > countries.inc.pl