#!/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