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