Koichi Taniguchi > Number-ZipCode-JP-0.20140829 > Number::ZipCode::JP

Download:
Number-ZipCode-JP-0.20140829.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.20140829   Source  

NAME ^

Number::ZipCode::JP - Validate Japanese zip-codes

SYNOPSIS ^

 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;

DESCRIPTION ^

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.

METHODS ^

new

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.

import

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.

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_number

Set/change the target zip-code. The syntax of arguments for this method is same as new() method (see above).

is_valid_number

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.

EXAMPLE ^

 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;

AUTHOR ^

Koichi Taniguchi (a.k.a. nipotan) <taniguchi@cpan.org>

LICENSE ^

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

SEE ALSO ^

Number::ZipCode::JP::Table

syntax highlighting: