From: Mischa POSLAWSKY Date: Sun, 1 Feb 2015 07:06:51 +0000 (+0100) Subject: countries: script to create include from geonames data X-Git-Tag: v1.6~55 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/49069763e748ef46dcb2587647a6f5c26bf04214 countries: script to create include from geonames data Great source which seems much more maintained than the outdated Locale::Object database used, and contains most wanted information (continents), except unfortunately missing reserved codes. --- diff --git a/tools/mkcountries-geonames b/tools/mkcountries-geonames new file mode 100755 index 0000000..0eaf880 --- /dev/null +++ b/tools/mkcountries-geonames @@ -0,0 +1,29 @@ +#!/usr/bin/env perl +use 5.012; +use warnings; + +my %cc; # map of country code to info array + +while (<>) { + /^#/ and next; # skip comments + my ($iso, $name, $cont) = (split /\t/)[0, 4, 8]; + my $class = "c-\L$cont"; + $cc{ lc $iso } = [ $name, $class ]; +} + +say "# automatically generated by $0"; +use Data::Dump 'dd'; +$Data::Dump::INDENT = ''; +dd \%cc; + +__END__ + +=head1 NAME + +mkcountries-geonames - Create Perl include of country info from GeoNames data + +=head1 SYNOPSIS + + curl http://download.geonames.org/export/dump/countryInfo.txt | + tools/mkcountryinfo > countries.inc.pl +