ip to decimal ip and back

U

uttamhoode

hi all,
i need a perl script to

1) convert ip address to decimal eg 127.0.0.1 to 2130706433

and

2)decimal to ip address 2130706433 to 127.0.0.1


uttam hoode
 
J

John W. Krahn

hi all,
i need a perl script to

1) convert ip address to decimal eg 127.0.0.1 to 2130706433

$ perl -MSocket -le'print unpack q/N/, inet_aton q/127.0.0.1/'
2130706433

and

2)decimal to ip address 2130706433 to 127.0.0.1

$ perl -MSocket -le'print inet_ntoa pack q/N/, 2130706433'
127.0.0.1



John
 
U

uttamhoode

Thanks John,
i would prefer Socket module to convert the ip address.
Regards,
uttam hoode
 
M

Mumia W.

hi all,
i need a perl script to

1) convert ip address to decimal eg 127.0.0.1 to 2130706433

Do a CPAN search for /::IP::/

I had to do this before, and it came down to using the right
combination of unpack, reverse, map, chr, and split. :-D

and

2)decimal to ip address 2130706433 to 127.0.0.1

I had to do this once, and it came down to using the right
combination of join, reverse, map, ord, split and pack.
uttam hoode

Good luck to you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,201
Messages
2,571,048
Members
47,647
Latest member
NelleMacy9

Latest Threads

Top