Parse::JapanesePostalCode - PostalCode Parser for 日本郵政
use Parse::JapanesePostalCode; my $parser = Parse::JapanesePostalCode->new( file => 'KEN_ALL.csv' ); while (my $obj = $parser->fetch_obj) { my @list = map { $_ ? $_ : () } ($obj->zip, $obj->pref, $obj->district, $obj->city, $obj->ward, $obj->town); if ($obj->has_subtown) { push @list, join '/', @{ $obj->subtown }; } if ($obj->build) { my $str = $obj->build; $str .= $obj->floor . 'F' if $obj->floor; push @list, $str; } }
Parse::JapanesePostalCode is a feel good parser to parse to Postal Code files that are provided by Japan Post.
Parse::JapanesePostalCode は、日本郵政が提供している郵便番号ファイルを良い感じにパースしてくれるパーサです。
create to parser instance.
read from file path.
my $parser = Parse::JapanesePostalCode->new( file => 'foo/bar/KEN_ALL.csv', );
read from file handle.
my $parser = Parse::JapanesePostalCode->new( fh => $ken_all_fh, );
ignore katakana_h2z.
my $parser = Parse::JapanesePostalCode->new( file => 'foo/bar/KEN_ALL.csv', katakana_h2z => 0, );
ignore alnum_z2h.
my $parser = Parse::JapanesePostalCode->new( file => 'foo/bar/KEN_ALL.csv', alnum_z2h => 0, );
get one line from KEN_ALL.csv.
while (my $line = $parser->get_line) { say $line; }
1行読み込みます。もし
07543,"97906","9790622","フクシマケン","フタバグントミオカマチ","ケガヤ(マエカワハラ232-244、311、312、337-862バンチ","福島県","双葉郡富岡町","毛萱(前川原232〜244、311、312、337〜862番地",1,1,0,0,0,0 07543,"97906","9790622","フクシマケン","フタバグントミオカマチ","トウキョウデンリョクフクシマダイ2ゲンシリョクハツデンショコウナイ)","福島県","双葉郡富岡町","〔東京電力福島第二原子力発電所構内〕)",1,1,0,0,0,0
のように複数行に分割されていたら、良い感じに行をマージした結果を返します。
get one line object from KEN_ALL.csv.
while (my $obj = $parser->fetch_obj) { say $obj->zip; }
get_line で取得した行を、 Parse::JapanesePostalCode::Row でオブジェクト化したオブジェクトを返します。
Kazuhiro Osawa <yappo {at} shibuya {dot} pl>
Parse::JapanesePostalCode::Row, http://www.post.japanpost.jp/zipcode/download.html
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Parse::JapanesePostalCode, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Parse::JapanesePostalCode
CPAN shell
perl -MCPAN -e shell install Parse::JapanesePostalCode
For more information on module installation, please visit the detailed CPAN module installation guide.