--- what_country.pl	Sun Oct 27 18:00:29 2002
+++ what_country.pl	Thu May 22 13:33:22 2003
@@ -50,22 +50,34 @@
 main_loop:
 while(<>){
     local $line = $_ ;
-    local ($ip1, $ip2, $ip3, $ip4) = /^(\d+)\.(\d+)\.(\d+)\.(\d+)/;
-    local $ip = ($ip1<<24) + ($ip2<<16) + ($ip3<<8) + $ip4;
-    
-    if( $ip > 0 ){
+    # print "DEBUG0: $line\n";
+
+    second_loop:
+    while ($line =~ /(\D*)(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(\D*)/) {
+	local $pre = $1;
+	local $ip1 = $2;
+	local $ip2 = $3;
+	local $ip3 = $4;
+	local $ip4 = $5;
+	local $post = $6;
+	local $ip = ($ip1<<24) + ($ip2<<16) + ($ip3<<8) + $ip4;
+	local $i;
+	local $value;
+	
 	$value = $ClassA_map{ $ip1 };
 	if( $value ){
-	    # print "$value\t$line";
-	    print "$value\n";
-	    next main_loop;
+	    print "$`$pre$ip1\.$ip2\.$ip3\.$ip4\($value\)$post";
+	    $line = $';
+	    # print "DEBUG1: $line\n";
+	    next second_loop;
 	}
 
 	$value = $ClassB_map{ ($ip1<<8) + $ip2 };
 	if( $value ){
-	    # print "$value\t$line";
-	    print "$value\n";
-	    next main_loop;
+	    print "$`$pre$ip1\.$ip2\.$ip3\.$ip4\($value\)$post";
+	    $line = $';
+	    # print "DEBUG2: $line\n";
+	    next second_loop;
 	}
 
 	for( $i = 1 ; $i < $index ;  $i++ ){
@@ -73,11 +85,17 @@
 		last;
 	    }
 	    if( $ip <= $ip_end_tab[$i] ){
-		# print "$cctld_tab[$i]\t$line";
-		print "$cctld_tab[$i]\n";
-		next main_loop;		
+		$value = $cctld_tab[$i];
+		print "$`$pre$ip1\.$ip2\.$ip3\.$ip4\($value\)$post";
+		$line = $';
+		# print "DEBUG3: $line\n";
+		next second_loop;
 	    }
 	}
-	print "unknown\t$line";
+	print "$`$pre$ip1\.$ip2\.$ip3\.$ip4\(\)$post";
+	$line = $';
+	# print "DEBUG4: $line\n";
+	next second_loop;
     }
+    print $line;
 }
