Geo::GNS::Parser - parse a GNS data file
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.)
Parse the GeoNET Names Server data
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.
file
data
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
&{callback} (undef, \%line);
Possible options are
The file name. This must be supplied or the module dies.
An array reference.
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 %line is a hash containing the parts of the line.
%line
User-specified data to pass to the callback routine. See l</callback> above.
http://geonames.nga.mil/gns/html/
Geolocator is a Python project using this data.
Ben Bullock, <bkb@cpan.org>
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.
To install Geo::GNS::Parser, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Geo::GNS::Parser
CPAN shell
perl -MCPAN -e shell install Geo::GNS::Parser
For more information on module installation, please visit the detailed CPAN module installation guide.