X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/8ee54859dde1136675f9c3cc2226984418094c0c..de20cc04f999154e97f8f0d041f536f048aed256:/tools/mkcountries-wikipedia diff --git a/tools/mkcountries-wikipedia b/tools/mkcountries-wikipedia new file mode 100755 index 0000000..67916dc --- /dev/null +++ b/tools/mkcountries-wikipedia @@ -0,0 +1,32 @@ +#!/usr/bin/env perl +use 5.012; +use warnings; + +my %cc; # map of country code to info array + +while (<>) { + /
/ .. /<\/pre>/ or next; # data is in preformatted block + m{ + \A (?[A-Z]{2}) + \h (? [A-Z]{2}) + \h \S* \h \d* # skip other iso codes + \h (? .+) + }x or next; + $cc{ lc $+{codea2} } = [ $+{name}, "c-\L$+{continent}" ]; +} + +use Data::Dump 'dd'; +$Data::Dump::INDENT = ''; +dd \%cc; + +__END__ + +=head1 NAME + +mkcountryinfo - Create Perl include of country info from Wikipedia page + +=head1 SYNOPSIS + + curl http://en.wikipedia.org/wiki/List_of_sovereign_states_and_dependent_territories_by_continent_%28data_file%29 | + tools/mkcountryinfo > countries.inc.pl +