NAME
Geo::GNS::Parser - parse a GNS data file
SYNOPSIS
use Geo::GNS::Parser 'parse_file';
my $in_file = 'ja.txt';
my %lines;
my $n_entries;
my $n_places;
parse_file (file => $in_file, callback => \& callback);
print "$n_entries / $n_places\n";
exit;
sub callback
{
my (undef, $line) = @_;
$n_entries++;
my @parts = split /\t/, $_;
my $ufi = $line->{UFI};
if (my $e = $lines{$ufi}) {
print "Duplicate $ufi for $line->{FULL_NAME_RO} $e->{FULL_NAME_RO}\n";
}
else {
$lines{$ufi} = $line;
$n_places++;
}
}
(This example is included as synopsis.pl in the distribution.)
DESCRIPTION
Parse the GeoNET Names Server data
FUNCTIONS
parse_file
parse_file (file => 'ja.txt', data => \@array);
Parse the data in the file specified by file and put the lines into the array specified by the data parameter.
parse_file (file => 'af.txt', callback => \& myroutine);
Parse the data in the file specified by file. As each line of data is parsed, call back the code routine specified by callback. The callback is called in the form
&{callback} (undef, \%line);
Possible options are
- file
-
The file name. This must be supplied or the module dies.
- data
-
An array reference.
- callback
-
A code reference to call back. If parse_file is called as
parse_file (%inputs);then the callback is called in the form
&{$inputs{callback}} ($inputs{callback_data}, \%line);where
%lineis a hash containing the parts of the line. - callback_data
-
User-specified data to pass to the callback routine. See l</callback> above.
SEE ALSO
- GeoNet Names Server
- geolocator
-
Geolocator is a Python project using this data.
AUTHOR
Ben Bullock, <bkb@cpan.org>
COPYRIGHT & LICENCE
This package and associated files are copyright (C) 2012-2017 Ben Bullock.
You can use, copy, modify and redistribute this package and associated files under the Perl Artistic Licence or the GNU General Public Licence.