묻고답하기

안녕하세요...반갑습니다.
이번에 정통부에서 발표한 우편번호를 가지고 우편번호db를 만들어는데...
찾기를 하면 않나오는 주소가 있습니다.
그래서 왜그런지 찾다보니 우편번호가 같은게 있으면 하나의 주소만 나오는것입니다.
예을 들어 "온천3동"를 검색하면 우편번호db에는 21개가 있는데 검색은 10개만됩니다.
그래서 원인을 찾아보니 우편번호가 동일하면 검색에서 하나만 나오고 나머지 주소는
나오지 않는것입니다.
동일한 우편번호가 있으면 주소중 하나만 출력하는것입니다.
간단하게 수정 할수없나요?

http://www.oktnt.com/Fmail/aaa/zip/zipcode.cgi

그럼 부탁좀 드림니다....
감사합니다.



#!/usr/bin/perl

##############################################################
# 우편번호 검색
# geonex@hanmail.net
##############################################################


&init;

if($GIL{'mode'} eq '') { &print_top; }
elsif($GIL{'mode'} eq 'top') { &show_top; }
elsif($GIL{'mode'} eq 'down') { &show_down; }
elsif($GIL{'mode'} eq 'search') { &search; }



##########################################################################
sub search {

        my $query = $GIL{'query'};

print "Content-type: text/htmlnn";
print<<END;
<html>
<head>
<SCRIPT language="JavaScript">
function Copy(zip1,zip2,address) {
        // copy
        top.opener.document.$GIL{form}.$GIL{zip1}.value = zip1;
        top.opener.document.$GIL{form}.$GIL{zip2}.value = zip2;
        top.opener.document.$GIL{form}.$GIL{address}.value = address;

        // focus
        top.opener.document.$GIL{form}.$GIL{address}.focus();

        // close this window
        parent.window.close();

}
</SCRIPT>
<TITLE>티사티 우편번호 검색</TITLE>
</head>
<style type="text/css">
<!--
body {font-family:굴림체; font-size:12px; text-decoration:none }
td { font-family:굴림체; font-size:12px; text-decoration:none}
        a:link { font-family:굴림체; font-size:12px; text-decoration:none; color:black}
a:visited { font-family:굴림체; font-size:12px; text-decoration:none; color:black}
a:hover { text-decoration: underline; color=#ff0000}
-->
</style>
<body bgcolor=white text=#000000>
<font size=2>
<center>
<table cellspacing=0 cellpadding=6 width=100%>
<tr align=center BGCOLOR=#4c81c><td><font size=-1><b>우편번호</b></font></td><td><font size=-1><b>주 소</b></font></td><td><font size=-1><b>확인</b></font></td></tr>

END

        require 'zipcode.pm';

        if($GIL{searchmode} eq 'address') {
                $ref = &zipcode_address($query);
        } elsif($GIL{searchmode} eq 'code') {
                $ref = &zipcode_code($query);
        }

        for(sort keys %$ref) {
                my ($zip1, $zip2) = $_ =~ /(...)(...)/;
                print qq|<tr BGCOLOR="#C3E5FF"><form><td><font color=black><input type='text' name='zip1' value='$zip1' size=3><b>-</b><input type='text' name='zip2' value='$zip2' size=3></font></td>
                                <td><input type='text' name='address'
value='$$ref{$_}' size=40 maxlength=50><br></font></td><td><input
type="button" value="적용" onClick="Copy('$zip1','$zip2','$$ref{$_}')"></td></form></tr>|;
        }

print <<END;

</table>
</font>

<hr size=1><center>
<font size=2 color=red><b>검색이 완료되었습니다.</b></font></center>
<hr size=1>
<FORM action=zipcode.cgi method=post name=gil>
<input type=hidden name=mode value=search>

<input type=hidden name=form value=$GIL{form}>
<input type=hidden name=zip1 value=$GIL{zip1}>
<input type=hidden name=zip2 value=$GIL{zip2}>
<input type=hidden name=address value=$GIL{address}>

<font size=2 color=#404040>
검색어: <input type=text name=query size=15>
<select name=searchmode size=1 onChange=document.gil.query.focus()>
<option value=address>주소로 찾기
<option value=code>우편번호로 찾기
</select>
<input type=submit value="검색">
</FORM>
</body>
</html>

END

}


##########################################################################
sub print_top {
print "Content-type: text/htmlnn";
print<<END;
<html>
<head>
<SCRIPT language="JavaScript">
</SCRIPT>
<TITLE>티사티 우편번호검색</TITLE>
</head>
<body bgcolor=white text=#000000 onLoad=document.gil.query.focus()>
<center>
<TABLE Width=400 CelLSpacing=0 CellPadding=6 Border=1 BorderColor=Black>
<TR>
   <TD BGCOLOR="gold" align="center">  <Font Size=2 Color=black>
<b>우편번호/주소 검색</b>
   </TD>
</TR>

<TR>
   <TD> <Font Size=2>

   <BR><CENTER>
<FONT SIZE=2 FACE="굴림체,arial">     찾고자 하는 주소의 동/읍/면 이름을 입력하세요.<br>     (예:압구정동/단양읍/수산면)</FONT>
<hr size=1>
<FORM action=zipcode.cgi method=post name=gil>
<input type=hidden name=mode value=search>

<input type=hidden name=form value=$GIL{form}>
<input type=hidden name=zip1 value=$GIL{zip1}>
<input type=hidden name=zip2 value=$GIL{zip2}>
<input type=hidden name=address value=$GIL{address}>

<font size=2 color=#404040>
검색어: <input type=text name=query size=15>
<select name=searchmode size=1 onChange=document.gil.query.focus()>
<option value=address>주소로 찾기
<option value=code>우편번호로 찾기
</select>
<input type=submit value="검색">
</FORM>
      </TD>
   </TR>
   </TABLE>
</center>
</body>
</html>

END

}





##########################################################################
sub init {
        if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }
        else { $buffer = $ENV{'QUERY_STRING'}; }

        for (split '&', $buffer) {
                my ($name, $value) = split '=';
                $name =~ tr/+/ /;  $name =~ s/%(..)/chr(hex($1))/ge;
                $value =~ tr/+/ /;  $value =~ s/%(..)/chr(hex($1))/ge;
                $GIL{$name} = $value;
        }

}


__END__