NAME

Geo::GeoNames::File - Perl module for handling GeoNames.org data files

SYNOPSIS

use Geo::GeoNames::File;

my $file = Geo::GeoNames::File->open( qw/US.txt GB.txt/ );

while( my $rec = $file->next() ) { print $rec->name . "\n"; }

$file->close();

DESCRIPTION

Provides a Perl extention for handling GeoNames.org data files. You may use this module to load GeoNames.org records from several seperate files.

AUTHOR

Xiangrui Meng <mengxr@stanford.edu>

COPYRIGHT

Copyright (C) 2009 by Xiangrui Meng

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

open()

Open files.

    my $file = Geo::GeoNames::File->open( @geonames_filenames );
close()

Close open file handles.

next()
    my $record = $batch->next();

Return the next record in the file as a Geo::GeoNames::Record object. If a filter function is supplied, it will return the next filtered record.

    sub pop_gt_100000
    {
       return (shift->population > 100000);
    }

    my $record = $file->next( \&pop_gt_100000 );