NAME

PT::PostalCode - Validates Portuguese Postal Codes

SYNOPSIS

use PT::PostalCode;

validate($postalcode);

code_is_from_area($postalcode,$city);
code_is_from_subarea($postalcode,$district);

code_is_from($postalcode,$district,$city);

range_from_subarea($district);

code_is_valid($code);
areas_of_code($code);
subareas_of_code($code);

DESCRIPTION

Validates Portuguese Postal Codes (that's the four digit code; in order to validate the seven digit codes of the form xxxx-xxx we would need a huge list of codes that would probably change every day).

PORTUGUESE POSTAL CODES

Regarding postal codes, Portugal is divided into areas and then into subareas. This division does not correspond to the most expected one (districts and then cities); instead, it was apparently made in a way it would be easier to redirect mail.

Postal codes in Portugal do not seem to follow any particular rule (but there was probably one in the beginning). There is no easy way of saying where a given code belongs to.

Each subarea has a minimum and a maximum code. This means it only allows for codes within that range. HOWEVER:

1) The existance of a range within a subarea does not imply the existance of every single code in it.

2) The existance of a code within a subarea does not mean the code does not exist in another area too.

THIS MEANS:

1) You can check if a code belongs to a certain area/subarea, but that does not mean it doesn't also belong to other(s) area(s)/subarea(s).

2) Even if a code is within the range of a certain subarea, that does not mean it is an existing code (that would need a huge list of codes, which is always subject to alterations).

MESSAGE FROM THE AUTHOR

If you're using this module, please drop me a line to my e-mail. Tell me what you're doing with it. Also, feel free to suggest new bugs^H^H^H^H^H features.

AUTHOR

Jose Alves de Castro, <cog [at] cpan [dot] org<gt>

COPYRIGHT AND LICENSE

Copyright 2004 by Jose Alves de Castro

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.