# ken2.pl
# 内容 :　郵便番号データを県別に分割するスクリプト
# Copyright (c) 2002 Mitsuo Minagawa, All rights reserved.
# (minagawa@fb3.so-net.ne.jp)          
# 使用方法 : c:\>perl ken2.pl
#
open(IN1,"ken_all.csv");	
open(OUT01,">01HOKKAIDO.CSV");	
open(OUT02,">02AOMORI.CSV");	
open(OUT03,">03IWATE.CSV");	
open(OUT04,">04MIYAGI.CSV");	
open(OUT05,">05AKITA.CSV");	
open(OUT06,">06YAMAGATA.CSV");	
open(OUT07,">07FUKUSHIMA.CSV");	
open(OUT08,">08IBARAKI.CSV");	
open(OUT09,">09TOCHIGI.CSV");	
open(OUT10,">10GUMMA.CSV");	
open(OUT11,">11SAITAMA.CSV");	
open(OUT12,">12CHIBA.CSV");	
open(OUT13,">13TOKYO.CSV");	
open(OUT14,">14KANAGAWA.CSV");	
open(OUT15,">15NIIGATA.CSV");	
open(OUT16,">16TOYAMA.CSV");	
open(OUT17,">17ISHIKAWA.CSV");	
open(OUT18,">18FUKUI.CSV");	
open(OUT19,">19YAMANASHI.CSV");	
open(OUT20,">20NAGANO.CSV");	
open(OUT21,">21GIFU.CSV");	
open(OUT22,">22SHIZUOKA.CSV");	
open(OUT23,">23AICHI.CSV");	
open(OUT24,">24MIE.CSV");	
open(OUT25,">25SHIGA.CSV");	
open(OUT26,">26KYOTO.CSV");	
open(OUT27,">27OSAKA.CSV");	
open(OUT28,">28HYOGO.CSV");	
open(OUT29,">29NARA.CSV");	
open(OUT30,">30WAKAYAMA.CSV");	
open(OUT31,">31TOTTORI.CSV");	
open(OUT32,">32SHIMANE.CSV");	
open(OUT33,">33OKAYAMA.CSV");	
open(OUT34,">34HIROSHIMA.CSV");	
open(OUT35,">35YAMAGUCHI.CSV");	
open(OUT36,">36TOKUSHIMA.CSV");	
open(OUT37,">37KAGAWA.CSV");	
open(OUT38,">38EHIME.CSV");	
open(OUT39,">39KOCHI.CSV");	
open(OUT40,">40FUKUOKA.CSV");	
open(OUT41,">41SAGA.CSV");	
open(OUT42,">42NAGASAKI.CSV");	
open(OUT43,">43KUMAMOTO.CSV");	
open(OUT44,">44OITA.CSV");	
open(OUT45,">45MIYAZAKI.CSV");	
open(OUT46,">46KAGOSHIMA.CSV");	
open(OUT47,">47OKINAWA.CSV");	
while	($line1	=	<IN1>)	{	
	chomp($line1);		
# CSV形式の $line1 から値を取り出して @in1 に入れる 
	my	$temp	=	$line1;	
	$temp	=~	s/(?:\x0D\x0A|[\x0D\x0A])?$/,/;	
	@in1	=	map	{/^"(.*)"$/	?	scalar($_	=	$1,	s/""/"/g,	$_)	:	$_}	
				($temp	=~	/("[^"]*(?:""[^"]*)*"|[^,]*),/g);		
	$w_ken		=	substr($in1[0],0,2);	
	$w_out		=	"OUT".$w_ken;	
	print	$w_out	"$line1\n";		
}	
close(IN1);	
close(OUT01);	
close(OUT02);	
close(OUT03);	
close(OUT04);	
close(OUT05);	
close(OUT06);	
close(OUT07);	
close(OUT08);	
close(OUT09);	
close(OUT10);	
close(OUT11);	
close(OUT12);	
close(OUT13);	
close(OUT14);	
close(OUT15);	
close(OUT16);	
close(OUT17);	
close(OUT18);	
close(OUT19);	
close(OUT20);	
close(OUT21);	
close(OUT22);	
close(OUT23);	
close(OUT24);	
close(OUT25);	
close(OUT26);	
close(OUT27);	
close(OUT28);	
close(OUT29);	
close(OUT30);	
close(OUT31);	
close(OUT32);	
close(OUT33);	
close(OUT34);	
close(OUT35);	
close(OUT36);	
close(OUT37);	
close(OUT38);	
close(OUT39);	
close(OUT40);	
close(OUT41);	
close(OUT42);	
close(OUT43);	
close(OUT44);	
close(OUT45);	
close(OUT46);	
close(OUT47);	
