in reply to convert longIP to stringIP
I would recommend using a module to handle IP addresses - my favourite is NetAddr::IP which works admirably but it won't solve your problem - you need a little more magic..
Your problem can be solved using this :
(Thanks to Luis E. Muņoz, author of NetAddr::IP, for the original tip)$n = get_number_from_database(); my $ip = NetAddr::IP->new($n < 0 ? 2**32 + $n : $n); # $ip now contain and IP object which can be printed , # or converted to binary, or checked for # subnet membership.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: convert longIP to stringIP
by fokat (Deacon) on Sep 14, 2003 at 14:50 UTC |