Re: ip to decimal ip and back



uttamhoode@xxxxxxxxx wrote in news:1155806520.935160.62520
@i42g2000cwa.googlegroups.com:

[ Please do not top-pots. Please do not quote sigs. ]

John W. Krahn wrote:
uttamhoode@xxxxxxxxx wrote:
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
....

Thanks John,
i would prefer Socket module to convert the ip address.

Your statement above is confusing. John Krahn's code *is* using the
Socket module.

Sinan

--
A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

.