5 my %cc; # map of country code to info array
8 /^#/ and next; # skip comments
9 my ($iso, $name, $cont) = (split /\t/)[0, 4, 8];
10 my $class = "c-\L$cont";
11 $cc{ lc $iso } = [ $name, $class ];
15 for ($_->[2] //= $_->[0]) {
21 s/ and / & /g and s/(?<=.)[a-z ]+//g;
23 s/South(?:ern)? /S-/g;
24 s/North(?:ern)? /N-/g;
26 s/(\S)(\S+)-/$1-/g; # strip most chars preceding dash
27 s/(\S{4}[b-df-hj-np-tv-xz])((?<!Austr)(?!land)\w{2,})/$1./g; # abbreviate (at consonant)
31 say "# automatically generated by $0";
33 $Data::Dump::INDENT = '';
40 mkcountries-geonames - Create Perl include of country info from GeoNames data
44 curl http://download.geonames.org/export/dump/countryInfo.txt |
45 tools/mkcountryinfo > countries.inc.pl