The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::Zipcode::TW

VERSION

version 1.0

SYNOPSIS

    ### Lookup
    say Data::Zipcode::TW->get('瑞穗'); #=> 978

    ### Reverse Lookup
    say Data::Zipcode::TW->get('404');  #=> 臺中市北區

    ### Ambiguous
    say Data::Zipcode::TW->get('中區'); #=> undef

    ### Disambiguated
    say Data::Zipcode::TW->get('臺中市北區'); #=> 404
    say Data::Zipcode::TW->get('臺南市北區'); #=> 704

    ### Not Found
    say Data::Zipcode::TW->get('這裡那裡');   #=> undef

    ### As Object Method
    my $zipcode = Data::Zipcode::TW->new;
    say $zipcode->get('新竹縣竹北');      #=> 302

DESCRIPTION

This module provides Taiwan Zipcode data. The original zip data can be downloaded from http://www.post.gov.tw/post/internet/down/index.html?ID=190108.

METHODS

get( $query )

This method takes a simple, non-ref scalar (String or Number) and returns a simple scalar (String or Number) or undef.

This method is the only method for the class and the instances of the class, it requires one argument, that is the query string.

When the query string is a number, it performs a reverse lookup (a zipcode-to-area-name lookup), and returns a long area name. Otherwise it is assumed the string means a long or short area name (described below), and returns the zipcode number.

Please reference this official table provided by the postal office website at http://download.post.gov.tw/post/download/臺灣地區郵遞區號前3碼一覽表_9912.txt for the area names that can be used in the query string.

Short names are those with zipcode numbers in the table, they are usually town names. Long names are short names prepened by their city/county names. For example, 大安區 or 瑞穗 are short names, while 臺北市大安區 is a long name. Notice there are two 大安區 in the table, one with zipcode 106, the other with zipcode 439.

Spaces must be removed in the query, you cannot use "竹 北" to perform the query, use "竹北" instead.

If the given $query is an ambiguours short name, undef is returned.

AUTHOR

Kang-min Liu <gugod@gugod.org>

COPYRIGHT

Copyright (c) 2011 Kang-min Liu <gugod@gugod.org>.

LICENCE

The MIT License

PROJECT DEVELOPMENT

See https://github.com/gugod/Data-Zipcode-TW

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.