in reply to Dotless IP address problem
This seems to work nicely.sub ip_to_dotless { return 0+ eval " 0x" . sprintf("%02x%02x%02x%02x", split(/\./, + shift)); } sub dotless_to_ip { my $hex=reverse sprintf("%x", shift); my @ip; for(0..3) { push(@ip, 0+ eval "0x" . reverse substr($hex, 0, 2, "" +)); } join('.', reverse @ip); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Dotless IP address problem
by guha (Priest) on Oct 19, 2001 at 00:46 UTC |