Hongyi Zhao wrote:
> Hi all,
>
> Suppose I've the entries like the following in my file:
>
> ------------------
> 116.52.155.237:80
> ip-72-55-191-6.static.privatedns.com:3128
> 222.124.135.40:80
> 217.151.231.34:3128
> 202.106.121.134:80
> 211.161.197.182:80
> hpc.be.itu.edu.tr:80
> static3-117-183.worldinternetworkcorporation.com:80
> ------------------
>
> Now, I want to convert the domain name to IP by using a perl script,
> any hints on this?
>
I'd use split /:/ to separate the address from the port number.
I'd use a regular expression to check if the address looks like an
ip-address. If your are confident of your data you can be a bit sloppy
and use something simple like m/^[0-9.]+$/ Otherwise read this
http://www.perlmonks.org/?node_id=221512
For addresses that look like a hostname+domain I'd use gethostbyname
--
RGB