NAME
Parse::JapanesePostalCode - PostalCode Parser for 日本郵政
SYNOPSIS
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;
}
}
DESCRIPTION
Parse::JapanesePostalCode is a feel good parser to parse to Postal Code files that are provided by Japan Post.
Parse::JapanesePostalCode は、日本郵政が提供している郵便番号ファイルを良い感じにパースしてくれるパーサです。
METHODS
new
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_line
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
のように複数行に分割されていたら、良い感じに行をマージした結果を返します。
fetch_obj
get one line object from KEN_ALL.csv.
while (my $obj = $parser->fetch_obj) {
say $obj->zip;
}
get_line で取得した行を、 Parse::JapanesePostalCode::Row でオブジェクト化したオブジェクトを返します。
AUTHOR
Kazuhiro Osawa <yappo {at} shibuya {dot} pl>
SEE ALSO
Parse::JapanesePostalCode::Row, http://www.post.japanpost.jp/zipcode/download.html
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.