#! /usr/bin/perl -w use strict; use Geo::Postcodes::NO 0.30; ################################################################################ # # # basic_no # # -------- # # Arne Sommer - perl@bbop.org - 9. September 2006 # # # ################################################################################ unless (@ARGV) { print "Usage: basic_no \n"; exit; } foreach my $postcode (@ARGV) { if (Geo::Postcodes::NO::valid($postcode)) { my $P = Geo::Postcodes::NO->new($postcode); foreach my $field (Geo::Postcodes::NO::get_fields()) # Iterate over the fields supported by a norwegian postcode object. { printf("%-10s\t%s\n", ucfirst($field), $P->$field() || ""), # Print the field name, and the result of the field call. } printf("%-10s\t%s\n\n", "Type_english", Geo::Postcodes::type2verbose($P->type())); # The english description for the type. } else # Not valid. { if (Geo::Postcodes::NO::legal($postcode)) { print "Postcode '$postcode' not in use.\n\n"; } else { print "Illegal postcode '$postcode'.\n\n"; } } }