Skip to content

Instantly share code, notes, and snippets.

@hexfusion
Last active December 30, 2015 16:09
Show Gist options
  • Save hexfusion/7852970 to your computer and use it in GitHub Desktop.
Save hexfusion/7852970 to your computer and use it in GitHub Desktop.
populate countries table with Locale::Country and DBIC
#! /usr/bin/env perl
use strict;
use warnings;
use Locale::Country;
use Interchange6::Schema;
my $dsn = shift;
my $schema = Interchange6::Schema->connect($dsn);
my @countries = ();
@countries = map {[$_, code2country($_)]} (all_country_codes(LOCALE_CODE_ALPHA_2));
#populate countries table
$schema->populate('Country', [
[ 'iso_code', 'name' ],
@countries,
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment