Number::ZipCode::JP - Validate Japanese zip-codes
use Number::ZipCode::JP; my $zip = Number::ZipCode::JP->new('100', '0001'); print "This is valid!!\n" if $zip->is_valid_number; $zip->set_number('100-0001'); print "This is valid!!\n" if $zip->is_valid_number; $zip->import(qw(area)); $zip->set_number('1000001'); print "This is valid!!\n" if $zip->is_valid_number;
Number::ZipCode::JP is a simple module to validate Japanese zip-code formats. The Japanese zip-codes are regulated by Japan Post Holdings Co., Ltd. You can validate what a target zip-code is valid from this regulation point of view.
There are some categories for type of construct in Japan. This module is able to be used narrowed down to the type of construct.
This module validates what a zip-code agrees on the regulation.
This method constructs the Number::ZipCode::JP instance. you can put some argument of a zip-code to it. It needs a two stuff for validation, area prefix and following (means an area suffix or a company-specific suffix).
If you put only one argument, this module will separate it by 4 digits and 3 digits. And you can put a non-numeric character between them.
It exists to select what categories is used for validation. You should pass some specified categories to this method.
Categories list is as follows:
Area ... area-specific zip-codes Company ... company-specific (includes P.O.Box) zip-codes
The category's names are ignored case. Actually, the import method calls others Number::ZipCode::JP::Table::Category module and import this. The default importing table, Number::ZipCode::JP::Table module is including all the categories table.
Number::ZipCode::JP::Table::
Number::ZipCode::JP::Table
For importing, you can import by calling this method, and you can import by calling this module with some arguments.
Example: # by calling import method use Number::ZipCode::JP; # import all the categories (default) my $zip = Number::ZipCode::JP->new->import(qw(company)); # by calling this module use Number::ZipCode::JP qw(company); my $zip = Number::ZipCode::JP->new; # same as above
Set/change the target zip-code. The syntax of arguments for this method is same as new() method (see above).
new()
This method validates what the already set number is valid on your specified categories. It returns true if the number is valid, and returns false if the number is invalid.
use Number::ZipCode::JP qw(area); my $zip = Number::ZipCode::JP->new; open FH, 'customer.list' or die "$!"; while (<FH>) { chomp; unless ($zip->set_number($_)->is_valid_number) { print "$_ is invalid number\n" } } close FH;
Koichi Taniguchi (a.k.a. nipotan) <taniguchi@livedoor.jp>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Number::ZipCode::JP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Number::ZipCode::JP
CPAN shell
perl -MCPAN -e shell install Number::ZipCode::JP
For more information on module installation, please visit the detailed CPAN module installation guide.