Geo::Postcodes::Update - Helper module for keeping the postcodes up to date
#! /usr/bin/perl -w
my $class = 'NO';
my $file = 'tilbud5';
my $url = 'http://epab.posten.no/Norsk/Nedlasting/_Files/tilbud5';
my $procedure = \&parse_no;
my $update = @ARGV && $ARGV eq "-update";
Geo::Postcodes::Update::update($class, $file, $url, $procedure, $update);
my @in = @_;
This is how the norwegian postcodes are treated, without showing the inner workings of parse_no which receives the lines from the file tilbud5 and returns suitable perl code for inclusion in the module. (The program is included as misc/update_no in the norwegian module.)
Run the program from the root (or the ./misc) directory of the distribution.
This module has only one external procedure.
Call this procedure with the following four parameters:
The name of the class in upper case letters, e.g. 'DK', 'NO' or 'U2'. This is a two-letter country code, as defined in ISO 3166-1, except for our utopian 'U2' (as used in the tutorial; perldoc Geo::Postcodes::Tutorial or man Geo::Postcodes::Tutorial).
The file where the postcodes are taken from. It is located in the ./misc directory of the distribution, together with the update_xx program.
An optional URL, where the program can download the postcode file if allowed to do so by the user. Use undef if no URL is available.
A pointer to a procedure that parses the postcode data. It will receive the lines from the postcode file as input, and must return a list of perl code lines with a suitable data structure, ready for writing to the country module file.
Set this to true to get the procedure to actually offer to update the module. It will display the perl code on-screen otherwise. This is usefull for debugging purposes when making the parsing procedure.
The update_* programs will do the following, when executed:
(URL Specified:) The program offers to fetch the postcode file, if it cannot locate the postcode file (in the ./misc directory). The user can decline the offer.
The program terminates if it cannot locate the postcode file (in the ./misc directory).
If the 'update' flag is not set, the program outputs the data structure (as lines of perl code on-screen) and terminates.
The program compares the data structure in the module with the one taken from the postcode file. The module is updated if the data structures differ, and the program will terminate.
The program terminates if it has fetched the postcode file already (in point 1).
As point 1.
As point 2.
As point 4.
This module requires the CPAN-module libwww-perl to work. It is used for semiautomatic downloading of the postcode file.
Copyright (C) 2006 by Arne Sommer - firstname.lastname@example.org
This library is free software; you can redistribute them and/or modify it under the same terms as Perl itself.
To install Geo::Postcodes, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.