develooper Front page | perl.beginners | Postings from October 2009

Want to write a script to note specific IP addresses.

Thread Next
From:
Hongyi Zhao
Date:
October 20, 2009 08:42
Subject:
Want to write a script to note specific IP addresses.
Message ID:
2huod51kleq8k2h53dektrsnu6a2rd96nv@4ax.com
Hi all,

I want to write a script to note specific IP
 addresses by appending the corresponding location informations.  For
detail, I describe my issue as follows:

Suppose I have two files, the first file is used to store the specific
IP
 addresses which I want to note, and the second file is used to store
the IP database along with the corresponding location informations.

The first file has one IP address per line with dotted decimal format,
e.g.:

0.125.125.125
4.19.79.28
4.36.124.150
...

The second file has four field per line delimited by CHARACTER
TABULATION (U+0009).  These four field are: StartIP, EndIP, Country,
and Local, e.g.:

StartIP	EndIP	Country	Local
0.0.0.0	0.255.255.255	IANA	CZ88.NET
4.19.79.0	4.19.79.63	American	Armed Forces
Radio/Television
4.36.124.128	4.36.124.255	American	Technical Resource
Connections Inc
...

Based on the second file, I want to reformat the first file by
appending the corresponding location informations for each IP address
in it, i.e., for the above example, I want to obain the following
result:

0.125.125.125#IANA CZ88.NET
4.19.79.28#American Armed Forces Radio/Television
4.36.124.150#American Technical Resource Connections
...

Any hints on this issue will be highly appreciated.
Thanks in advance.
-- 
.: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About